ptSend/index.js
2023-08-08 20:47:46 +08:00

31 lines
1010 B
JavaScript

const Koa = require('koa');
const app = new Koa();
const static = require('koa-static')
app.use(static("./view/dist"))
const {koaBody} = require('koa-body');
const KoaSSEStream = require('koa-sse-stream');
app.use(koaBody());
app.use(async (ctx, next) => {
ctx.set('Access-Control-Allow-Origin', '*');
ctx.set('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With');
ctx.set('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
if (ctx.method == 'OPTIONS') {
ctx.body = 200;
} else {
await next();
}
});
const index = require("./router/index.js")
app.use(index.routes()).use(index.allowedMethods())
const videoInfo = require("./router/videoInfo.js");
const config = require("./router/config.js");
app.use(config.routes()).use(config.allowedMethods())
app.use(videoInfo.routes()).use(videoInfo.allowedMethods())
app.listen(3050, "0.0.0.0");
// 引入定时检测更新
require("./util/Video/Update.js")