-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
79 lines (67 loc) · 2.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import express from 'express';
import dotenv from 'dotenv';
import reportRoutes from './routes/reportRoutes.js';
import userRoutes from './routes/userRoutes.js';
import roleRoutes from './routes/roleRoutes.js';
import userRoleRouter from './routes/userRoleRoutes.js';
import authRoutes from './routes/authRoutes.js';
import applicationRoutes from './routes/applicationRoutes.js';
import errorHandler from './middlewares/errorHandler.js';
import cors from 'cors';
import db from './models/index.js';
import newsletterRoutes from './routes/newsletterRoutes.js';
import listEndpoints from 'express-list-endpoints'; // Import express-list-endpoints
//import employeeRoutes from './routes/employeeRoutes.js'
import adminRoutes from './routes/adminRoutes.js'
//import agencyRoutes from './routes/agencyRoutes.js'
//import employerRoutes from './routes/employerRoutes.js'
import jobRoutes from './routes/jobRoutes.js'
import countryRoutes from './routes/countryRoutes.js'
import uploadRoutes from './routes/uploadRoutes.js'
import upload from './middlewares/upload.js';
import { uploadFile } from './controllers/uploadController.js'
import employeeRoutes from './routes/employeeRoutes.js';
import { sendVerificationEmail,sendPasswordResetEmail,sendForgetPasswordEmail, } from './controllers/emailController.js';
import emailRoutes from './routes/emailRoutes.js';
import coursesRoutes from './routes/coursesRoutes.js';
import PaymentRoutes from './routes/PaymentRoutes.js';
const sequelize = db.sequelize;
dotenv.config();
const app = express();
// Add middleware to log incoming requests
app.use((req, res, next) => {
console.log(`Received request: ${req.method} ${req.url}`);
next();
});
app.use(cors());
app.use(express.json());
app.use(errorHandler);
await sequelize.sync({ alter: true }).then(() => {
console.log("Tables created.");
}).catch(err => {
console.log(err);
});
app.use('/api/v1', userRoutes);
app.use('/api/v1', roleRoutes);
app.use('/api/v1', userRoleRouter);
app.use('/api/v1', authRoutes);
app.use('/api/v1/', reportRoutes);
//app.use('/api/v1/', employerRoutes);
app.use('/api/v1/', jobRoutes);
app.use('/api/v1/', applicationRoutes);
app.use('/api/v1/', countryRoutes);
app.use('/api/v1/subscribe', newsletterRoutes);
app.use('/api/v1/upload', upload.single('file'), uploadFile);
app.use('/api/v1/', employeeRoutes)
app.use('/api/v1/', emailRoutes)
app.use('/api/v1/', coursesRoutes)
app.use('/api/v1/', PaymentRoutes)
app.use ('/api/v1/', adminRoutes)
// Get a list of registered endpoints
const endpoints = listEndpoints(app);
console.log('Registered endpoints:');
console.log(endpoints);
const port = process.env.PORT;
app.listen(port, () => {
console.log(`Server started at localhost:${port}`);
});