forked from EGF2/auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (28 loc) · 1.16 KB
/
server.js
File metadata and controls
34 lines (28 loc) · 1.16 KB
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
"use strict";
var restify = require("restify");
var controller = require("./controller");
var logger = require("./components").logger;
var server = restify.createServer({
name: "auth",
log: logger
});
server.use(restify.queryParser());
server.use(restify.bodyParser());
function processResult(handler) {
return function(req, res, next) {
Promise.resolve()
.then(() => handler(req, res))
.then(result => res.send(result))
.catch(next);
};
}
server.post("/v1/register", processResult(controller.register));
server.post("/v1/resend_email_verification", processResult(controller.resendEmailVerification));
server.get("/v1/verify_email", processResult(controller.verifyEmail));
server.post("/v1/login", processResult(controller.login));
server.get("/v1/logout", processResult(controller.logout));
server.get("/v1/forgot_password", processResult(controller.forgotPassword));
server.post("/v1/reset_password", processResult(controller.resetPassword));
server.post("/v1/change_password", processResult(controller.changePassword));
server.get("/v1/internal/session", processResult(controller.session));
module.exports = server;