mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: lazy-require model
This commit is contained in:
1 parent
a4d7dc4b04
commit
514078132e
4 files changed
+12
-16
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.20.11",
|
"version": "2.20.12",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
/* eslint-disable func-names */
|
/* eslint-disable func-names */
|
||||||
import { isClass } from './utils';
|
import { isClass } from './utils';
|
||||||
import { PERMS } from './model/builtin';
|
|
||||||
|
|
||||||
interface IHydroError {
|
interface IHydroError {
|
||||||
new(...args: any[]): HydroError
|
new(...args: any[]): HydroError
|
||||||
@@ -78,7 +77,7 @@ export const VerifyPasswordError = Err('VerifyPasswordError', ForbiddenError, "P
|
|||||||
export const OpcountExceededError = Err('OpcountExceededError', ForbiddenError, 'Too frequent operations of {0} (limit: {2} operations in {1} seconds).');
|
export const OpcountExceededError = Err('OpcountExceededError', ForbiddenError, 'Too frequent operations of {0} (limit: {2} operations in {1} seconds).');
|
||||||
export const PermissionError = Err('PermissionError', ForbiddenError, function () {
|
export const PermissionError = Err('PermissionError', ForbiddenError, function () {
|
||||||
if (typeof this.params[0] === 'bigint') {
|
if (typeof this.params[0] === 'bigint') {
|
||||||
this.params[0] = PERMS.find(({ key }) => key === this.params[0])?.desc || this.params[0];
|
this.params[0] = require('./model/builtin').PERMS.find(({ key }) => key === this.params[0])?.desc || this.params[0];
|
||||||
}
|
}
|
||||||
return "You don't have the required permission ({0}) in this domain.";
|
return "You don't have the required permission ({0}) in this domain.";
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ export interface HistoryDoc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Discussion
|
// Discussion
|
||||||
export { Ddoc } from './model/discussion';
|
export type { Ddoc } from './model/discussion';
|
||||||
declare module './model/discussion' {
|
declare module './model/discussion' {
|
||||||
interface Ddoc {
|
interface Ddoc {
|
||||||
docType: document['TYPE_DISCUSSION'],
|
docType: document['TYPE_DISCUSSION'],
|
||||||
|
|||||||
@@ -3,17 +3,6 @@
|
|||||||
/* eslint-disable import/no-dynamic-require */
|
/* eslint-disable import/no-dynamic-require */
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
/* eslint-disable no-eval */
|
/* eslint-disable no-eval */
|
||||||
import './interface';
|
|
||||||
import os from 'os';
|
|
||||||
import path from 'path';
|
|
||||||
import cluster from 'cluster';
|
|
||||||
import fs from 'fs-extra';
|
|
||||||
import { argv } from 'yargs';
|
|
||||||
import wtfnode from 'wtfnode';
|
|
||||||
import './utils';
|
|
||||||
|
|
||||||
export * from './interface';
|
|
||||||
|
|
||||||
if (!global.Hydro) {
|
if (!global.Hydro) {
|
||||||
global.Hydro = {
|
global.Hydro = {
|
||||||
stat: { reqCount: 0 },
|
stat: { reqCount: 0 },
|
||||||
@@ -41,11 +30,19 @@ if (!global.Hydro) {
|
|||||||
};
|
};
|
||||||
global.addons = [];
|
global.addons = [];
|
||||||
}
|
}
|
||||||
|
import './interface';
|
||||||
|
import os from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
import cluster from 'cluster';
|
||||||
|
import fs from 'fs-extra';
|
||||||
|
import { argv } from 'yargs';
|
||||||
|
import wtfnode from 'wtfnode';
|
||||||
|
import './utils';
|
||||||
import { Logger } from './logger';
|
import { Logger } from './logger';
|
||||||
import './ui';
|
import './ui';
|
||||||
import * as bus from './service/bus';
|
import * as bus from './service/bus';
|
||||||
|
|
||||||
|
export * from './interface';
|
||||||
const logger = new Logger('loader');
|
const logger = new Logger('loader');
|
||||||
logger.debug('%o', argv);
|
logger.debug('%o', argv);
|
||||||
bus.on('app/exit', () => {
|
bus.on('app/exit', () => {
|
||||||
|
|||||||
Reference in new issue
Block a user