core: add provideModule and injectUI API

This commit is contained in:
undefined committed 2022-09-23 01:36:12 +08:00
1 parent 672c553f4c
commit 28f03dbcbd
18 files changed
+211 -97

No files matched your search

+8 -10
View File
@@ -1,6 +1,5 @@
import 'hydrooj';
import superagent from 'superagent';
import { PluginContext } from 'hydrooj';
import { ForbiddenError } from 'hydrooj/src/error';
declare module 'hydrooj' {
@@ -9,9 +8,6 @@ declare module 'hydrooj' {
'login-with-github.secret': string;
'login-with-github.endpoint': string;
}
interface Lib {
oauth_github: typeof import('./lib');
}
}
async function get() {
@@ -75,8 +71,10 @@ async function callback({ state, code }) {
return ret;
}
global.Hydro.lib.oauth_github = {
text: 'Login with Github',
callback,
get,
};
export function apply(ctx:PluginContext) {
ctx.provideModule('oauth', 'github', {
text: 'Login with Github',
callback,
get,
});
}