-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (21 loc) · 722 Bytes
/
index.js
File metadata and controls
27 lines (21 loc) · 722 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
// install express with `npm install express`
const express = require("express");
const { json } = require("express");
const verifyToken = require("./app/middleware/headers");
const AuthController = require("./app/auth/auth_controller");
const AuthService = require("./app/auth/auth_service");
const Config = require("./app/config");
const app = express();
app.use(json());
app.use("/", AuthController);
// THIS ENDPOINT RETURNS EVERY USER ON "users" table
app.get("/demo", verifyToken, async (req, res) => {
if (await AuthService.verifyUser(req.token)) {
res.send("you are signed");
} else {
res.send("forbidden")
}
});
app.listen(Config.PORT, () => {
console.log("listening on: " + Config.PORT)
})