-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
58 lines (42 loc) · 1.68 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const express = require('express');
const app = express();
const path = require('path');
const morgan = require('morgan');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const PORT = process.env.PORT || 5000;
const routes = require('./api/routes');
const passport = require('passport');
require('./passport'); //for passport.js file
const passportAuth = passport.authenticate('jwt', {session: false});
// connection to mongodb
mongoose.connect("mongodb://localhost:27017/HRAssist");
// Middlewares
app.use(morgan("dev"));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// For CORS
// app.use((req, res, next) => {
// res.header("Access-Control-Allow-Origin", "*");
// })
app.use(express.static(path.join(__dirname, 'app')));
//All routes
app.use('/api/auth', routes.authRoute);
app.use('/api/view_salary',passportAuth, routes.salaryRoute);
app.use('/api/view_shifts',passportAuth, routes.shiftRoute);
app.use('/api/designations',passportAuth, routes.desigRoute);
app.use('/api/view_settings',passportAuth, routes.settingRoute);
app.use('/api/overtime',passportAuth, routes.overtimeRoute);
app.use('/api/employees',passportAuth, routes.employeeRoute);
app.use('/api/attendances',passportAuth, routes.attendanceRoute);
// /* GET home page. */
// app.get('/', function (req, res) {
// //Path to your main file
// console.log('path from /', path.join(__dirname + '/app/index.html'));
// res.status(200).sendFile(path.join(__dirname + '/app/index.html'));
// });
// app.get('*', function(req, res){
// // console.log(path.join(__dirname + './app/index.html'));
// res.render('./app/index.html');
// });
module.exports = app;