core: experimental hot reload support

This commit is contained in:
undefined committed 2022-09-20 22:34:36 +08:00
1 parent 632ae27b88
commit fd7c9cbeb1
26 files changed
+429 -148

No files matched your search

+4 -5
View File
@@ -2,7 +2,7 @@ import { makeExecutableSchema } from '@graphql-tools/schema';
import { graphql, GraphQLSchema } from 'graphql';
import { resolvers, typeDefs } from 'graphql-scalars';
import * as bus from '../service/bus';
import { Handler, Route } from '../service/server';
import { Handler } from '../service/server';
const types: Record<string, Record<string, string>> = {};
const unions: Record<string, string> = {};
@@ -123,8 +123,7 @@ class ApiHandler extends Handler {
}
}
export function apply() {
Route('api', '/api', ApiHandler);
export const sideEffect = true;
export function apply(ctx) {
ctx.Route('api', '/api', ApiHandler);
}
global.Hydro.handler.api = apply;
+5 -7
View File
@@ -119,11 +119,9 @@ class BlogEditHandler extends BlogHandler {
}
}
export async function apply() {
Route('blog_main', '/blog/:uid', BlogUserHandler);
Route('blog_create', '/blog/:uid/create', BlogEditHandler, PRIV.PRIV_USER_PROFILE);
Route('blog_detail', '/blog/:uid/:did', BlogDetailHandler);
Route('blog_edit', '/blog/:uid/:did/edit', BlogEditHandler, PRIV.PRIV_USER_PROFILE);
export async function apply(ctx) {
ctx.Route('blog_main', '/blog/:uid', BlogUserHandler);
ctx.Route('blog_create', '/blog/:uid/create', BlogEditHandler, PRIV.PRIV_USER_PROFILE);
ctx.Route('blog_detail', '/blog/:uid/:did', BlogDetailHandler);
ctx.Route('blog_edit', '/blog/:uid/:did/edit', BlogEditHandler, PRIV.PRIV_USER_PROFILE);
}
global.Hydro.handler.blog = apply;
+3 -3
View File
@@ -1,4 +1,4 @@
import { Handler, Route } from '../service/server';
import { Handler } from '../service/server';
class ProblemCategoryCompatHandler extends Handler {
async get({ category }) {
@@ -6,6 +6,6 @@ class ProblemCategoryCompatHandler extends Handler {
}
}
global.Hydro.handler.compat = () => {
Route('problem_category_compat', '/p/category/:category', ProblemCategoryCompatHandler);
export const apply = (ctx) => {
ctx.Route('problem_category_compat', '/p/category/:category', ProblemCategoryCompatHandler);
};
-17
View File
@@ -1,17 +0,0 @@
import './home';
import './problem';
import './record';
import './judge';
import './user';
import './contest';
import './training';
import './discussion';
import './manage';
import './import';
import './misc';
import './homework';
import './domain';
import './status';
import './api';
import './blog';
import './compat';
-26
View File
@@ -1,26 +0,0 @@
/* eslint-disable no-empty-function */
/* eslint-disable class-methods-use-this */
import { NotFoundError } from '../error';
import {
Handler, param, Route, Types,
} from '../service/server';
class NotFoundHandler extends Handler {
@param('bsod', Types.Boolean)
prepare(domainId: string, bsod: boolean) {
if (bsod) throw new Error(this.request.path);
throw new NotFoundError(this.request.path);
}
get() { }
post() { }
head() { }
put() { }
delete() { }
}
export async function apply() {
Route('notfound', '(/.*)+', NotFoundHandler);
}
global.Hydro.handler.notfound = apply;