-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (23 loc) · 846 Bytes
/
index.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
const express = require('express');
const path = require('path')
// const users = require('./UserData')
const app = express();
//Body parser Middleware
app.use(express.json());
app.use(express.urlencoded({ extended: false }))
// //Getting all users
// app.get('/api/users', (req, res) => res.json(users))
// //Getting single user
// app.get('/api/users/:id', (req, res) => {
// res.json(users.filter(user => user.id === parseInt(req.params.id)));
// })
//users API route
app.use('/api/users', require('./routes/api/users'));
//Static Folder
// app.get('/', (req, res) => {
// // res.send("API is working");
// res.sendFile(path.join(__dirname,'public','index.html'))
// })
app.use(express.static(path.join(__dirname, 'public')))
const port = 5000;
app.listen(port, () => { console.log("Server started on port", port); });