-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
58 lines (51 loc) · 1.46 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
const express = require("express")
const morgan = require("morgan")
const cors = require("cors")
const parser = require("body-parser")
const db = require("./app/db")
const { pageRouter, baseRouter } = require("./app/routes")
const app = express()
app.set("port", process.env.PORT || 3000)
app.use(morgan("dev"))
app.use(cors())
app.use(parser.json())
// Connect routers
app.use(pageRouter)
app.use(baseRouter)
app.get("/search", function(req, res) {
console.log(req.query)
console.log(req.query.query)
let pages = [
{
title: "Email Forwarding",
slug: "email-forwarding",
contributors: ["Jeffrey Chan", "Kathy Daniels"],
content: "<h1>EMAIL FORWARDING AND ALIASING</h1> <p>Written by Jeffrey Chan</p>"
},
{
title: "Joining IEEE",
slug: "joining-ieee",
contributors: ["Jeffrey Chan", "Kathy Daniels"],
content: "<h1>EMAIL FORWARDING AND ALIASING</h1> <p>Written by Jeffrey Chan</p>"
},
{
title: "Webmaster 101",
slug: "webmaster",
contributors: ["Jeffrey Chan", "Kathy Daniels"],
content: "<h1>EMAIL FORWARDING AND ALIASING</h1> <p>Written by Jeffrey Chan</p>"
}
]
res.json(pages)
})
app.get("/user/:email", function(req, res) {
console.log(req.params.email)
let user = {
firstName: "Jeffrey",
lastName: "Chan",
email: "[email protected]"
}
res.json(user)
})
app.listen(app.get("port"), function() {
console.log(`Started server at port ${app.get("port")}.`)
})