-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (42 loc) · 1.54 KB
/
index.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
const express = require('express');
const cors = require('cors');
const helmet = require('helmet');
const config = require('./config/index');
const db = require('./lib/db');
const { logErrors, errorHandler, } = require('./utils/middleware/errorHandler');
//Routes Call
const userRoutes = require('./api/components/user/routes');
const authRoutes = require('./api/components/auth/routes');
const jobOfferRoutes = require('./api/components/jobOffer/routes');
const masterStudentRoutes = require('./api/components/masterStudent/routes');
const jobApplicationRoutes = require('./api/components/jobApplication/routes');
const companyRoutes = require('./api/components/company/routes');
//Models
const User = require('./models/users');
const ApiKey = require('./models/apiKeys');
const JobOffer = require('./models/jobOffers');
const MasterStudent = require('./models/masterStudents');
const JobApplication = require('./models/jobApplications');
const Company = require('./models/companies');
const app = express();
app.use(cors())
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(helmet());
app.get('/api', (req, res) => {
res.send('Hello World');
});
//Database Connect
db.connect();
//Routes
userRoutes(app, User);
authRoutes(app, ApiKey);
jobOfferRoutes(app, JobOffer);
masterStudentRoutes(app, MasterStudent);
jobApplicationRoutes(app, JobApplication);
companyRoutes(app, Company);
app.use(logErrors);
app.use(errorHandler);
app.listen(config.port, () => {
console.log(`Server Listening at http://localhost:${config.port}`);
})