Skip to content

Instantly share code, notes, and snippets.

View disaada's full-sized avatar
:octocat:
cat mama

Disa Ada disaada

:octocat:
cat mama
View GitHub Profile
const user = require('./routes/user')
app.get('/user/:id', authenticateJWT, user.getUser)
app.put('/user/:id', authenticateJWT, user.updateUser)
app.delete('/user/:id', authenticateJWT, user.deleteUser)
@disaada
disaada / index.js
Last active September 20, 2020 04:43
app.post('/signin', (req, res) => {
/* step 1 : mengambil data email dan password yang telah diisi oleh user */
const { email, password } = req.body
/* step 2 : mengambil data user di db berdasarkan email yang dimasukkan user */
Model.user.findOne({ where: { email } })
.then((data) => {
/* data dari db didapat, bandingkan password yg diinput dengan yg ada di db */
if (data && (bcrypt.compareSync(password, data.password))) {
/* buat token menggunakan jwt.sign(data, 'secretkey', waktu_expired) */
const token = jwt.sign({ data }, 'secret', { expiresIn: '1h' })
@disaada
disaada / 0.md
Created August 12, 2020 04:24 — forked from max-mapper/0.md
JS hoisting by example

JavaScript function hoisting by example

Below are many examples of function hoisting behavior in JavaScript. Ones marked as works successfuly print 'hi!' without errors.

To play around with these examples (recommended) clone them with git and execute them with e.g. node a.js

Notes on hoisting

(I may be using incorrect terms below, please forgive me)