-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (39 loc) · 1.01 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
import cookieParser from 'cookie-parser';
import cors from 'cors';
import { config } from 'dotenv';
import express from 'express';
import ErrorMiddleware from './middlewares/Error.js';
config({
path: './config/config.env',
});
const app = express();
// Using Middlewares
app.use(express.json({ limit: '50mb' }));
app.use(
express.urlencoded({
extended: true,
})
);
app.use(cookieParser());
app.use(
cors({
origin: process.env.FRONTEND_URL,
methods: ['GET', 'POST', 'PUT', 'DELETE'],
})
);
// Importing & Using Routes
import course from './routes/courseRoutes.js';
import other from './routes/otherRoutes.js';
import payment from './routes/paymentRoutes.js';
import user from './routes/userRoutes.js';
app.use('/api/v1', course);
app.use('/api/v1', user);
app.use('/api/v1', payment);
app.use('/api/v1', other);
export default app;
app.get('/', (req, res) =>
res.send(
`<h1>Site is Working. click <a href=${process.env.FRONTEND_URL}>here</a> to visit frontend.</h1>`
)
);
app.use(ErrorMiddleware);