mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
更加严格的lib&model定义
This commit is contained in:
1 parent
76b001305d
commit
cd3a426ef8
8 files changed
+42
-9
No files matched your search
@@ -1,6 +1,12 @@
|
||||
import 'hydrooj';
|
||||
import TurndownService from 'turndown';
|
||||
|
||||
declare module 'hydrooj' {
|
||||
interface Lib {
|
||||
convertHTML: (str: string) => string,
|
||||
}
|
||||
}
|
||||
|
||||
const turndownService = new TurndownService({
|
||||
headingStyle: 'atx',
|
||||
codeBlockStyle: 'fenced',
|
||||
|
||||
@@ -7,8 +7,10 @@ import pslist from 'ps-list';
|
||||
import { argv } from 'yargs';
|
||||
import { builtinModel } from './common';
|
||||
import { Entry } from '../loader';
|
||||
import { Logger } from '../logger';
|
||||
import * as bus from '../service/bus';
|
||||
|
||||
const logger = new Logger('entry/master');
|
||||
const tmpdir = path.resolve(os.tmpdir(), 'hydro');
|
||||
const lockfile = path.resolve(tmpdir, 'lock.json');
|
||||
|
||||
@@ -19,7 +21,7 @@ export async function load(call: Entry) {
|
||||
const file = require(lockfile);
|
||||
const plist = await pslist();
|
||||
if (file.pid && plist.map((i) => i.pid).includes(file.pid)) {
|
||||
console.error(`Lockfile exists, pid=${file.pid}`);
|
||||
logger.error(`Lockfile exists, pid=${file.pid}`);
|
||||
process.exit(1);
|
||||
}
|
||||
} catch {
|
||||
@@ -37,9 +39,9 @@ export async function load(call: Entry) {
|
||||
require('../error');
|
||||
const config = require('../options')();
|
||||
if (!config) {
|
||||
console.log('Starting setup');
|
||||
logger.info('Starting setup');
|
||||
await call({ entry: 'setup', newProcess: true }).catch((err) => {
|
||||
console.error('Cannot start setup process.', err);
|
||||
logger.error('Cannot start setup process.', err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -199,7 +199,6 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
|
||||
class HomeworkCreateHandler extends HomeworkHandler {
|
||||
async get() {
|
||||
const beginAt = moment().add(1, 'day');
|
||||
console.log(beginAt, beginAt.tz(this.user.timeZone));
|
||||
const penaltySince = beginAt.clone().add(7, 'days');
|
||||
const path = [
|
||||
['Hydro', 'homepage'],
|
||||
@@ -343,7 +342,6 @@ class HomeworkEditHandler extends HomeworkHandler {
|
||||
class HomeworkScoreboardHandler extends HomeworkHandler {
|
||||
@param('tid', Types.ObjectID)
|
||||
async get(domainId: string, tid: ObjectID) {
|
||||
console.log(123);
|
||||
const [tdoc, rows, udict] = await this.getScoreboard(
|
||||
domainId, tid, false, document.TYPE_HOMEWORK,
|
||||
);
|
||||
|
||||
@@ -410,6 +410,13 @@ export interface JudgeResultBody {
|
||||
stderr?: string,
|
||||
}
|
||||
|
||||
export interface Task {
|
||||
_id: ObjectID,
|
||||
type: string,
|
||||
executeAfter?: Date
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export type PathComponent = [string, string, Dictionary<any>?, boolean?];
|
||||
|
||||
export interface Collections {
|
||||
@@ -428,7 +435,7 @@ export interface Collections {
|
||||
'status': any,
|
||||
'oauth': any,
|
||||
'system': System,
|
||||
'task': any,
|
||||
'task': Task,
|
||||
'opcount': any,
|
||||
'fs.chunks': any,
|
||||
'fs.files': any,
|
||||
@@ -454,7 +461,7 @@ export interface Model {
|
||||
token: typeof import('./model/token'),
|
||||
training: typeof import('./model/training'),
|
||||
user: typeof import('./model/user'),
|
||||
[key: string]: any,
|
||||
oauth: typeof import('./model/oauth'),
|
||||
}
|
||||
|
||||
export interface Service {
|
||||
@@ -463,7 +470,11 @@ export interface Service {
|
||||
gridfs: GridFSBucket,
|
||||
monitor: typeof import('./service/monitor'),
|
||||
server: typeof import('./service/server'),
|
||||
[key: string]: any,
|
||||
}
|
||||
|
||||
interface GeoIP {
|
||||
provider: string,
|
||||
lookup: (ip: string, locale?: string) => any,
|
||||
}
|
||||
|
||||
export interface Lib {
|
||||
@@ -484,7 +495,8 @@ export interface Lib {
|
||||
'testdata.convert.ini': typeof import('./lib/testdata.convert.ini'),
|
||||
useragent: typeof import('./lib/useragent'),
|
||||
validator: typeof import('./lib/validator'),
|
||||
[key: string]: any
|
||||
template?: any,
|
||||
geoip?: GeoIP,
|
||||
}
|
||||
|
||||
export interface UI {
|
||||
|
||||
@@ -10,6 +10,9 @@ declare module 'hydrooj' {
|
||||
'login-with-github.secret': string,
|
||||
'login-with-github.proxy': string,
|
||||
}
|
||||
interface Lib {
|
||||
oauth_github: typeof import('./lib'),
|
||||
}
|
||||
}
|
||||
|
||||
async function get() {
|
||||
|
||||
@@ -10,6 +10,9 @@ declare module 'hydrooj' {
|
||||
'login-with-google.secret': string,
|
||||
'login-with-google.proxy': string,
|
||||
}
|
||||
interface Lib {
|
||||
oauth_google: typeof import('./lib'),
|
||||
}
|
||||
}
|
||||
|
||||
async function get() {
|
||||
|
||||
@@ -10,6 +10,9 @@ declare module 'hydrooj' {
|
||||
'login-with-osu.secret': string,
|
||||
'login-with-osu.proxy': string,
|
||||
}
|
||||
interface Lib {
|
||||
oauth_osu: typeof import('./lib'),
|
||||
}
|
||||
}
|
||||
|
||||
const BASE_URL = 'https://osu.ppy.sh/';
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import 'hydrooj';
|
||||
import 'hydrooj/dist/utils';
|
||||
|
||||
declare module 'hydrooj' {
|
||||
interface Lib {
|
||||
oauth_qq: typeof import('./lib'),
|
||||
}
|
||||
}
|
||||
|
||||
async function get() {
|
||||
const { system, token } = global.Hydro.model;
|
||||
const secret = String.random(8);
|
||||
|
||||
Reference in new issue
Block a user