-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
35 lines (28 loc) · 961 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
const express = require('express');
const path = require('path');
require('dotenv').config();
const PORT = process.env.PORT || 3030;
const app = express();
//------- Middlewares -------//
app.use(express.json());
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});
// Landing page route
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, '/index.html'));
});
// Base Todo Router
const _router = require('./src/router/Router');
require('./src/router/UserRoutes')(app);
require('./src/router/NavRoutes')(app);
// Add more router here as per your application needs
_router(app);
// Running App
app.listen(PORT, () => {
console.log(`App is running: http://localhost:${PORT}`);
console.log(`API running: http://localhost:${PORT}/todos`);
console.log(`API running: http://localhost:${PORT}/users`);
});