-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (28 loc) · 697 Bytes
/
app.js
File metadata and controls
34 lines (28 loc) · 697 Bytes
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
var express = require('express');
var bodyParser = require('body-parser');
var zxcvbn = require('zxcvbn');
var app = express();
app.use(bodyParser.json());
app.post('*', function (req, res, next) {
if (req.body.password) {
next();
} else {
res
.status(400)
.json({
error: {
code: 400,
message: "password missing in POST body"
}
});
}
});
app.post('/zxcvbn', function (req, res) {
res.send(zxcvbn(req.body.password));
});
app.post('/zxcvbn/score', function (req, res) {
res.send({
score: zxcvbn(req.body.password).score
});
});
module.exports = app;