-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (29 loc) · 917 Bytes
/
server.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
// Main server file
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const userRoutes = require('./routes/userRoutes');
const adminRoutes = require('./routes/adminRoutes');
const app = express();
const PORT = process.env.PORT || 5000;
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, 'client')));
// Routes
// User routes
app.use('/user', userRoutes);
// Admin routes
app.use('/admin', adminRoutes);
//html routes
app.get('/about', (req, res, next) => {
res.sendFile(__dirname + '/client/about.html');
});
app.get('/form', (req, res, next) => {
res.sendFile(__dirname + '/client/form.html');
});
app.get('/', (req, res, next) => {
res.sendFile(__dirname + '/client/index.html');
});
app.listen(PORT, () => {
console.log(`Server has started on port ${PORT}`);
});