1 Star 0 Fork 4

JY/node-danmu

forked from smile/node-danmu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.js 1.59 KB
一键复制 编辑 原始数据 按行查看 历史
smile 提交于 2020-05-16 13:57 . 手机扫码支付demo
'use strict'
const express = require('express')
const session = require('express-session')
const path = require('path')
const cors = require('cors')
const logger = require('./utils/logger')
const app = express()
require('./server/nms')
require('./db/connect')
/*
//压缩html css js静态文件
const compression = require('compression')
//尽量在其他中间件前使用compression
app.use(compression());
*/
//跨域访问
app.use(cors({
origin: ['http://localhost', 'http://localhost:81'],
credentials: true
}))
//session
app.use(
session({
cookie: {maxAge: 7 * 24 * 60 * 60 * 1000},
secret: 'gdgdgjhr4yhrtghfg',
resave: true,
saveUninitialized: false
})
)
//静态文件路径
app.use('/res', express.static(path.join(__dirname, './upload'), {
maxAge: '1y',
etag: false
}))
// 解析json 和表单
app.use(express.json())
app.use(express.urlencoded({extended: true}))
//路由
app.use('/user', require('./router/userRouter'))
app.use('/upload', require('./router/fileRouter'))
app.use('/video', require('./router/videoRouter'))
app.use('/danmu', require('./router/danmuRouter'))
app.use('/comment', require('./router/commentRouter'))
app.use('/live', require('./router/liveRouter'))
app.use('/msg', require('./router/messageRouter'))
app.use('/notice', require('./router/noticeRouter'))
//app.use('/qrCode', require('./router/qrRouter'))
//管理员路由
app.use('/admin', (req, res, next) => {
// if (req.url === '/login' || req.session.login) next()
// else res.sendStatus(403)
next()
}, require('./router/adminRouter'))
app.listen(3000, args => logger.newInfo('服务器启动'))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/crazyjy233/node-danmu.git
git@gitee.com:crazyjy233/node-danmu.git
crazyjy233
node-danmu
node-danmu
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385