-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (24 loc) · 724 Bytes
/
Copy pathapp.js
File metadata and controls
28 lines (24 loc) · 724 Bytes
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
console.log("From app.js");
const Joi = require('joi')
const express = require('express');
const app = express()
app.use(express.json())
// Importing all the routes
const listItems=require("./routes/items");
const dbListItems=require("./routes/dbItems.js")
app.use("/api/items",listItems);
app.use("/api/db",dbListItems);
//PORT
app.get("/api",(req,res)=>{
console.log("Requested for :"+req.hostname)
res.send("API is working...")
},error=>{
console.log("Invalid request");
console.log(error)
res.status(404).send("Not Found")
})
const port = process.env.PORT || 3000
app.listen(port, () => {
console.log(`Listening on port ${port}... "`);
console.log("Started server on :" + new Date())
});