Skip to content

Beberapa Pembaruan #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
9 changes: 0 additions & 9 deletions CATATAN_GMAIL_MAILER.md

This file was deleted.

15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@

Backend ini hanya digunakan untuk mengirim email konfirmasi pendaftaran ke member yang baru daftar.

Untuk menggunakan GMAIL API silahkan lihat sebuah catatan di file [CATATAN_GMAIL_MAILER.md](./CATATAN_GMAIL_MAILER.md).

Untuk bagian frontend dapat dilihat di [Frontend-Web-Pendaftaran-KoLU](https://github.com/KomunitasLinuxUPN/Website-Pendaftaran-KoLU.git).

---

## Untuk Para Kontributor dan _Maintainer_

#### Tentang Ekstensi

- Dianjurkan untuk memasang ekstensi ESLint untuk pengguna VSCode, karena proyek ini menggunakan ESLint untuk menjaga kualitas dan konsistensi kode.

#### Tentang _commit_

- Dimohon untuk tidak melakukan _commit_ langsung ke _branch main_. Dimohon untuk membuat _branch_ baru untuk setiap pekerjaan anda, lalu _push_ branch tersebut ke _repository_ ini dan lakukan _pull request_ ke _branch main_.

---
Expand All @@ -36,6 +29,14 @@ $ npm run dev
$ npm start
```

## Catatan Konfigurasi Gmail Mailer

- Turtorial Konfigurasi APInya:
https://www.youtube.com/watch?v=JJ44WA_eV8E
- Jangan lupa cek komentarnya *Nikolai Stakheiko* biar bisa jalan
- Boleh cek ini buat menuju ke URL console API-nya:
https://developers.google.com/gmail/api/quickstart/js

---

> Sebagian isi README mengutip dari README [web-pendaftaran-seed](https://github.com/pps-ti/web-pendaftaran-seed) milik Lab PPS-TI UPN "Veteran" Jawa Timur
16 changes: 3 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
{
"name": "backend-pendaftaran-kolu",
"version": "1.1.0",
"description": "Backend Web Pendaftaran KoLU",
"private": true,
"main": "dist/app.js",
"scripts": {
"dev": "nodemon dist/app.js",
"start": "node dist/app.js"
},
"keywords": [
"node",
"typescript",
"express",
"gmailer",
"nodemailer"
],
"author": "mramirid",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
Expand All @@ -39,7 +29,7 @@
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"nodemon": "^2.0.6",
"typescript": "^4.1.2"
"nodemon": "^2.0.15",
"typescript": "^4.5.3"
}
}
36 changes: 18 additions & 18 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ dotenv.config();
* EmailSendedResponse adalah struktur response data balikan dari Gmail API
* ketika email konfirmasi berhasil dikirim
*/
interface EmailSendedResponse {
accepted: string[]
rejected: string[]
envelopeTime: number
messageTime: number
messageSize: number
response: string
type EmailSendedResponse = {
accepted: string[];
rejected: string[];
envelopeTime: number;
messageTime: number;
messageSize: number;
response: string;
envelope: {
from: string
to: string[]
}
messageId: string
}
from: string;
to: string[];
};
messageId: string;
};

/*
* RegConfirmBody adalah struktur request body yang akan dikirim oleh frontend
Expand All @@ -41,10 +41,10 @@ interface EmailSendedResponse {
* Struktur RegConfirmBody disini HARUS MIRIP dengan
* struktur RegConfirmBody yang ada di projek frontend
*/
interface RegConfirmBody {
destEmail: string
confirmationURL: string
}
type RegConfirmBody = {
destEmail: string;
confirmationURL: string;
};

/*
* Gmailer Middleware
Expand All @@ -58,7 +58,7 @@ interface RegConfirmBody {
*/
app.use(async (req, res) => {
try {
const { destEmail, confirmationURL } = (req.body as RegConfirmBody);
const { destEmail, confirmationURL } = req.body as RegConfirmBody;

const emailTemplate = await ejs.renderFile(
Path.join(__dirname, '/templates/confirmation.ejs'),
Expand Down Expand Up @@ -114,7 +114,7 @@ app.use(async (req, res) => {
moreInfo: error,
});
});
} catch (err) {
} catch (err: any) {
res.status(400).send({
message: err.message || 'An error occurred',
});
Expand Down