-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (41 loc) · 1.36 KB
/
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
37
38
39
40
41
42
const express = require("express")
const spdy = require('spdy')
const fs = require("fs")
const bodyParser = require("body-parser")
const cors = require('cors')
// 引入文件
const carrerRouter = require("./routes/career.router")
const articleRouter = require("./routes/article.router")
// 配置
const app = express()
const httpsOption = {
key: fs.readFileSync("./https/3888548_modestfun.com.key"),
cert: fs.readFileSync("./https/3888548_modestfun.com.pem")
}
app.use(cors())
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
const hostname = "localhost"
const port = 3030
// 监听
// spdy.createServer(httpsOption, app).listen(port,()=>{
// console.log(`Server running at http://${hostname}:${port}!`)
// })
app.listen(port, () => {
console.log(`Server running at http://${hostname}:${port}!`)
})
// 历程路由
app.use("/api-career", carrerRouter)
app.use("/api-article", articleRouter)
// 博客首页路由
// app.use("/static", express.static('./build/static'));
// app.use("/assets", express.static('./build/assets'));
// app.get('/', function (req, res) {
// res.sendFile(path.resolve('./build/index.html'));
// })
// app.get('/:id', function (req, res) {
// res.sendFile(path.resolve('./build/index.html'));
// })
// app.get('/:id/:id', function (req, res) {
// res.sendFile(path.resolve('./build/index.html'));
// })