-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
40 lines (32 loc) · 979 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
36
37
38
39
40
import express from "express";
import cors from "cors";
import bodyparser from "body-parser";
import cookieParser from "cookie-parser";
import connectdb from './config/db.js';
import path from 'path';
const __dirname = path.dirname(new URL(import.meta.url).pathname);
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: false }))
app.use(express.static('public'));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(cookieParser());
app.use(cors({
origin: '/'
}));
connectdb();
app.listen(process.env.PORT || 3005, function(){
console.log("➡️ UIET Connect listening on port %d in %s mode 👍", this.address().port, app.settings.env);
});
import APIs from './APIs/alumniDetail.js';
app.use('/api', APIs);
import pages from './routes/pages.js';
app.use('/', pages)
app.get('*',async(req,res,next)=>{
try {
res.render('error');
} catch (error) {
next(error)
}
});