-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (30 loc) · 939 Bytes
/
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
// 导入 express
const express = require('express')
// 创建服务器的实例对象
const app = express()
// 导入test路由
const routerTest = require('./test/index')
// 导入login.js路由
const loginRouter = require('./router/login')
// 导入user.js路由
const userRouter = require('./router/user')
// 导入files.js路由
const filesRouter = require('./router/files')
// 引入跨域插件
const cors = require('cors');
// 引入body-parser 处理Body
const bodyParser = require('body-parser')
// 导入path
const path = require('path')
app.use(cors());
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }));
// 托管图片资源
app.use('/cloudAvatar', express.static('./public/cloudAvatar'))
app.use('/test', routerTest)
app.use('/cloud', loginRouter)
app.use('/api', userRouter)
app.use('/api', filesRouter)
app.listen(5007, () => {
console.log('api server running at http://127.0.0.1:5007')
})