-
Notifications
You must be signed in to change notification settings - Fork 0
/
middleware.js
49 lines (42 loc) · 1.09 KB
/
middleware.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//#region // SQL //
///////////////////
// const { DB } = require('./db.js');
////////////
//#endregion
//#region // PRE-PROCESS //
///////////////////
// exports.buffer = (req, res, next) => {
// req.pass = Buffer.from(req.body.pass.toString(), 'binary').toString('base64')
// next()
// }
////////////
//#endregion
//#region // LOG //
///////////////////
exports.log = () => {
return (req, res, next) => {
console.log(req.query.boenk)
next()
}
}
////////////
//#endregion
//#region // AUTHENTICATE //
///////////////////
exports.test = (req, res, next) => {
if (req.headers.authorization !== 'Basic QXp1cmEEaWFb25kOmh5bnRlcjI=') {
res.set('WWW-Authenticate', 'Basic realm="401"')
res.status(401).send('Authentication failed')
return
} else res.send(req.headers.authorization)
if (req.pass == "Let me in !!!") {
next();
}
// res.redirect('/');
}
////////////
//#endregion
// if (req.headers['content-type'] !== 'application/json') {
// res.status(400).send('Server requires application/json')
// } else {
// next()