mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
upgrade dep:
css-loader 0.28->3.5 del 4.1->5.1 eslint 5.18->6.8 eslint-config-airbnb 17.1->18.1 eslint-loader 2.1->4.0 file-loader 2.0->6.0 fs.extra 8.0->9.0 gulp 2.0->3.0 gulp-nunjucks 4.0->5.0 json-loader 0.5->Removed style-loader 0.23->1.1 uglifyjs-webpack-plugin 1.3->2.2 yargs 13.2->15.3 katex 0.10->0.11 react-monaco-editor 0.35->0.36 timeage-react 1.2->3.0 timeago.js 3.0->4.0 uuid 3.3->7.0
This commit is contained in:
1 parent
9cb68397b9
commit
f9468536de
55 files changed
+776
-1032
No files matched your search
+10
-1
@@ -6,6 +6,14 @@ class UserFacingError extends Error {
|
||||
this.params = [];
|
||||
}
|
||||
}
|
||||
class SystemError extends Error {
|
||||
constructor(type) {
|
||||
super(type);
|
||||
this.code = 500;
|
||||
// this.stack = '';
|
||||
this.params = [];
|
||||
}
|
||||
}
|
||||
class BadRequestError extends UserFacingError {
|
||||
constructor(type) {
|
||||
super(type);
|
||||
@@ -154,7 +162,8 @@ module.exports = {
|
||||
ValidationError, ProblemNotFoundError, TrainingNotFoundError,
|
||||
ContestNotFoundError, RecordNotFoundError, SolutionNotFoundError,
|
||||
AlreadyVotedError, ContestNotAttendedError, ContestNotLiveError,
|
||||
ContestScoreboardHiddenError, ContestAlreadyAttendedError
|
||||
ContestScoreboardHiddenError, ContestAlreadyAttendedError, UserFacingError,
|
||||
SystemError
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -52,7 +52,6 @@ async function run() {
|
||||
await coll_user.createIndex('unameLower', { unique: true });
|
||||
await coll_user.createIndex('mailLower', { sparse: true });
|
||||
await coll_role.insertMany(builtin.BUILTIN_ROLES);
|
||||
await coll_user.insertMany(builtin.BUILTIN_USERS);
|
||||
await coll_blacklist.createIndex('expireAt', { expireAfterSeconds: 0 });
|
||||
await coll_token.createIndex([{ uid: 1 }, { tokenType: 1 }, { updateAt: -1 }], { sparse: true });
|
||||
await coll_token.createIndex('expireAt', { expireAfterSeconds: 0 });
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const
|
||||
path = require('path'),
|
||||
{ ObjectID } = require('bson'),
|
||||
{ MongoError } = require('mongodb'),
|
||||
Koa = require('koa'),
|
||||
morgan = require('koa-morgan'),
|
||||
Body = require('koa-body'),
|
||||
@@ -14,7 +15,7 @@ const
|
||||
token = require('../model/token'),
|
||||
opcount = require('../model/opcount'),
|
||||
{ UserNotFoundError, BlacklistedError, PermissionError,
|
||||
NotFoundError } = require('../error');
|
||||
NotFoundError, UserFacingError } = require('../error');
|
||||
|
||||
const options = require('../options');
|
||||
let http = options.listen.https ? require('https') : require('http');
|
||||
@@ -60,6 +61,7 @@ class Handler {
|
||||
url_prefix: '/'
|
||||
};
|
||||
this._handler = {};
|
||||
this.session = {};
|
||||
}
|
||||
renderHTML(name, context) {
|
||||
console.time(name);
|
||||
@@ -130,7 +132,7 @@ class Handler {
|
||||
await this.renderBody();
|
||||
} catch (error) {
|
||||
if (this.preferJson) this.response.body = { error };
|
||||
else await this.render('bsod.html', { error });
|
||||
else await this.render(error instanceof UserFacingError ? 'error.html' : 'bsod.html', { error });
|
||||
}
|
||||
await this.putResponse();
|
||||
await this.saveCookie();
|
||||
@@ -186,9 +188,9 @@ class Handler {
|
||||
async onerror(error) {
|
||||
console.error(error.message, error.params);
|
||||
console.error(error.stack);
|
||||
this.response.template = 'error.html';
|
||||
this.response.template = error instanceof UserFacingError ? 'error.html' : 'bsod.html';
|
||||
this.response.body = { error };
|
||||
await this.___cleanup();
|
||||
await this.___cleanup().catch(() => { });
|
||||
}
|
||||
}
|
||||
function Route(route, handler) {
|
||||
|
||||
Reference in new issue
Block a user