update dep

This commit is contained in:
masnn committed 2020-04-08 21:44:39 +08:00
1 parent 7dc31d02fa
commit 36989b1942
7 files changed
+265 -80

No files matched your search

-1
View File
@@ -45,7 +45,6 @@ MIDDLEWARE(async (ctx, next) => {
}
};
ctx.csrf_token = await token.add(token.TYPE_CSRF_TOKEN, 600, ctx.path);
console.log(ctx.session.uid);
await next();
if (ctx.session.sid)
await token.update(ctx.session.sid, tokenType, expireSeconds, Object.assign({
-2
View File
@@ -27,7 +27,6 @@ GET('/judge/fetch', requirePerm(PERM_JUDGE), async ctx => {
else ctx.body = {};
});
POST('/judge/next', requirePerm(PERM_JUDGE), async ctx => {
console.log(ctx.request.body);
let body = ctx.request.body;
let rdoc = await record.get(body.rid);
let $set = {};
@@ -51,7 +50,6 @@ POST('/judge/next', requirePerm(PERM_JUDGE), async ctx => {
ctx.body = {};
});
POST('/judge/end', requirePerm(PERM_JUDGE), async ctx => {
console.log(ctx.request.body);
let body = ctx.request.body;
let rdoc = await record.get(body.rid);
let $set = {};
+14 -5
View File
@@ -1,8 +1,8 @@
const
path = require('path'),
static = require('koa-static'),
send = require('koa-send'),
nunjucks = require('nunjucks'),
hljs = require('hljs'),
hljs = require('highlight.js'),
MarkdownIt = require('markdown-it'),
katex = require('markdown-it-katex'),
options = require('../options'),
@@ -75,15 +75,24 @@ class Nunjucks extends nunjucks.Environment {
this.addGlobal('status', builtin.STATUS);
}
}
const env = new Nunjucks();
MIDDLEWARE(static(path.resolve(process.cwd(), '.uibuild')));
let env = new Nunjucks();
MIDDLEWARE(async (ctx, next) => {
let done = false;
if (ctx.method === 'HEAD' || ctx.method === 'GET')
try {
done = await send(ctx, ctx.path, { root: path.resolve(process.cwd(), '.uibuild'), index: 'index.html' });
} catch (err) {
if (err.status !== 404) throw err;
}
if (!done) await next();
});
MIDDLEWARE(async (ctx, next) => {
ctx.render_title = str => str;
ctx.UIContext = {
cdn_prefix: '/',
url_prefix: '/'
};
ctx.preferJson = ctx.request.headers['accept'].includes('application/json');
ctx.preferJson = (ctx.request.headers['accept'] || '').includes('application/json');
ctx.render = async (name, context) => {
ctx.user = ctx.state.user;
ctx.translate = str => {