2023-06-14 15:43:04 +08:00
|
|
|
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');
|
2023-06-28 21:11:21 +08:00
|
|
|
|
2023-06-14 15:43:04 +08:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
});
|
2023-06-12 15:20:45 +08:00
|
|
|
|
2023-06-14 15:43:04 +08:00
|
|
|
const index = require("./router/index.js")
|
|
|
|
app.use(index.routes()).use(index.allowedMethods())
|
2023-06-28 21:11:21 +08:00
|
|
|
const videoInfo = require("./router/videoInfo.js");
|
2023-06-14 15:43:04 +08:00
|
|
|
|
2023-06-28 21:11:21 +08:00
|
|
|
app.use(videoInfo.routes()).use(videoInfo.allowedMethods())
|
|
|
|
app.listen(3050, "0.0.0.0");
|
|
|
|
console.log("link: http://127.0.0.1:3050")
|