-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (20 loc) · 915 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
//Node and express is all about routing
import express from "express";
import bodyParser from "body-parser";
//Bodyparser allow us to take in incoming request body
import apiRouter from "./routes/users.js";
//We can change usersRouter to anything we like but that name is a good representation
const app = express();
//The whole applications rest in this var called app
const PORT = 5000;
//This can be any number
app.use(bodyParser.json());
//json stand for java script object notation. It's common format sending or request to a rest API
//We need to use /users to acces usersRouter
app.use('/api', apiRouter);
//'/' usually it's for homepage
app.get('/', (req, res) => res.send('Hello from Homepage.'));
//This is for make another route
app.listen(PORT, () => console.log(`Server Running on port: http://localhost:${PORT}`));
//Listen is for recieve a request and executed when we run our server
//Gege