-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
60 lines (43 loc) · 1.36 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const express = require('express')
const cors = require('cors')
const app = express()
const fruitRouter = require('./routes/fruitRouter')
app.get('/', (req, res) => {
res.send('Hello World!')
})
//CORS
app.use(cors())
app.use(express.json())
app.use('/fruits', fruitRouter)
module.exports = app
// //Importing express framework - to setup server
// const express = require('express')
// //initialising server that's gonna allow us to receive requests and
// const app = express()
// //above 1024 - integers
// const port = 3000
// app.get('/home', (req, res) => {
// res.send("hey")
// })
// app.get('/dogs', (req, res) => {
// res.send("hello, dog!")
// })
// //dynamic parameter, req params contain all the name
// app.get('/dogs/:name', (req, res) => {
// //ress.status().send()
// res.status(200).send(req.params.name)
// //res.sendStatus(200)
// //This will translate wt is sent into JSON
// res.json()
// //will end the res process without sending any data
// res.end()
// })
// // server/app.METHOD('PATH', (req, res) => {
// //logic
// //sd bk a res
// //res.send(<data>) if you don't include this line of code the server will keep hanging
// // })
// // binding the server to a port, call bk is a function within a function
// app.listen(port, () => {
// console.log(`Example app listening on port ${port}`)
// })