-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (29 loc) · 994 Bytes
/
app.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
require("dotenv").config();
const express = require('express');
const cors = require('cors')
const app = express();
const bodyp = require('body-parser');
app.use(bodyp.json());
app.use(bodyp.urlencoded({ extended: true }));
app.use(cors());
//Import Middleware
const auth = require('./src/middleware/auth');
//Import Controller
const { getService } = require('./src/controller/guestController');
const { userRegist, userLogin } = require('./src/controller/authController');
const { getProfile, userService } = require('./src/controller/userController');
//Routes List
app.post('/auth/register', userRegist);
app.post('/auth/login', userLogin);
//User Routes
app.get('/user/me', auth, getProfile);
app.all('/user/*', auth, userService);
app.get('/', (req, res) => {
return res.status(200).json({
status: 'success',
message: 'Welcome to Panenesia Service'
});
});
//Guest Routes
app.get('*', getService);
module.exports = app;