|
1 | 1 | // Main server file
|
2 |
| -const express = require("express"); |
3 |
| -const path = require("path"); |
4 |
| -const bodyParser = require("body-parser"); |
| 2 | +const express = require('express'); |
| 3 | +const path = require('path'); |
| 4 | +const bodyParser = require('body-parser'); |
| 5 | +const userRoutes = require('./routes/userRoutes'); |
| 6 | +const adminRoutes = require('./routes/adminRoutes'); |
5 | 7 |
|
6 | 8 | const app = express();
|
7 | 9 |
|
8 |
| -const userRoutes = require("./routes/userRoutes"); |
9 |
| - |
10 | 10 | const PORT = process.env.PORT || 5000;
|
11 | 11 |
|
12 | 12 | app.use(bodyParser.urlencoded({ extended: true }));
|
13 | 13 | app.use(bodyParser.json());
|
14 | 14 |
|
15 |
| -app.use(express.static(path.join(__dirname, "client"))); |
| 15 | +app.use(express.static(path.join(__dirname, 'client'))); |
16 | 16 |
|
17 | 17 | // Routes
|
18 | 18 |
|
19 |
| -// User route |
20 |
| -app.use("/user", userRoutes); |
| 19 | +// User routes |
| 20 | +app.use('/user', userRoutes); |
| 21 | + |
| 22 | +// Admin routes |
| 23 | +app.use('/admin', adminRoutes); |
| 24 | + |
| 25 | +//html routes |
| 26 | +app.get('/about', (req, res, next) => { |
| 27 | + res.sendFile(__dirname + '/client/about.html'); |
| 28 | +}); |
| 29 | + |
| 30 | +app.get('/form', (req, res, next) => { |
| 31 | + res.sendFile(__dirname + '/client/form.html'); |
| 32 | +}); |
21 | 33 |
|
22 |
| -app.get("/", (req, res, next) => { |
23 |
| - res.sendFile(__dirname + "/client/index.html"); |
| 34 | +app.get('/', (req, res, next) => { |
| 35 | + res.sendFile(__dirname + '/client/index.html'); |
24 | 36 | });
|
25 | 37 |
|
26 | 38 | app.listen(PORT, () => {
|
27 |
| - console.log("Server has started"); |
| 39 | + console.log(`Server has started on port ${PORT}`); |
28 | 40 | });
|
0 commit comments