-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
59 lines (50 loc) · 1.49 KB
/
test.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
50
51
52
53
54
55
56
57
58
59
import { env } from '@frontierjs/backend';
import helmet from 'helmet';
import cors from 'cors';
import express from 'express';
import bodyParser from 'body-parser';
import AuthController from '$c/AuthController';
import UserController from '$c/UserController';
//register, login, logout, refreshtokens, verify
let router = express.Router();
router.use(bodyParser.urlencoded({ extended: false }));
router.use(bodyParser.json());
router.use('/', (req, res, next) => {
// console.log({body: req.body})
next();
});
// router.use('/template', TemplateRouter)
router.get(
'/users',
AuthController.authenticateTokenMiddleware,
UserController.index
);
router.get('/users/free', UserController.index);
router.get(
'/users/all',
AuthController.authenticateTokenMiddleware,
UserController.all
);
router.post('/users', UserController.store);
router.delete('/users/:id', UserController.destroy);
router.patch('/users/:id/restore', UserController.restore);
router.post('/register', AuthController.register);
router.post('/login', AuthController.login);
router.post('/refresh', AuthController.refresh);
router.get(
'/verify',
AuthController.authenticateTokenMiddleware,
AuthController.verify
);
router.post('/logout', AuthController.logout);
let server = express();
server.use(cors());
server.use(helmet());
server.use(helmet.hidePoweredBy({ setTo: 'PHP 3.3.0' }));
server.use('/api/v1', router);
let port = env.get('PORT');
server.listen(port, () =>
console.log(`
Server listening on port ${port}!
`)
);