core: allow homepage config injection

pull/456/head
undefined 2 years ago
parent 4f41c0ae56
commit a2ea3812df

@ -9,6 +9,7 @@ const compilerOptionsBase = {
module: 'commonjs', module: 'commonjs',
esModuleInterop: true, esModuleInterop: true,
moduleResolution: 'node', moduleResolution: 'node',
jsx: 'react',
sourceMap: false, sourceMap: false,
composite: true, composite: true,
strictBindCallApply: true, strictBindCallApply: true,

@ -9,7 +9,7 @@ if [ $EUID != 0 ]; then
fi fi
set -e set -e
echo "Executing Hydro install script v3.0.0" echo "Executing Hydro install script v3.0.0"
echo "Hydro includes anonymous system telemetry, echo "Hydro includes system telemetry,
which helps developers figure out the most commonly used operating system and platform. which helps developers figure out the most commonly used operating system and platform.
To disable this feature, checkout our sourcecode." To disable this feature, checkout our sourcecode."
mkdir -p /data/db /data/file ~/.hydro mkdir -p /data/db /data/file ~/.hydro

@ -114,7 +114,7 @@ export class HomeHandler extends Handler {
} }
async get({ domainId }) { async get({ domainId }) {
const homepageConfig = system.get('hydrooj.homepage'); const homepageConfig = this.domain.homepage || system.get('hydrooj.homepage');
const info = yaml.load(homepageConfig) as any; const info = yaml.load(homepageConfig) as any;
const contents = []; const contents = [];
for (const column of info) { for (const column of info) {

@ -453,18 +453,15 @@ export async function apply(pluginContext: Context) {
rewrite: (p) => p.replace('/fs', ''), rewrite: (p) => p.replace('/fs', ''),
}); });
app.use(async (ctx, next) => { app.use(async (ctx, next) => {
for (const key in captureAllRoutes) {
if (ctx.path.startsWith(key)) return captureAllRoutes[key](ctx, next);
}
if (!ctx.path.startsWith('/fs/')) return await next(); if (!ctx.path.startsWith('/fs/')) return await next();
if (ctx.request.search.toLowerCase().includes('x-amz-credential')) return await proxyMiddleware(ctx, next); if (ctx.request.search.toLowerCase().includes('x-amz-credential')) return await proxyMiddleware(ctx, next);
ctx.request.path = ctx.path = ctx.path.split('/fs')[1]; ctx.request.path = ctx.path = ctx.path.split('/fs')[1];
return await next(); return await next();
}); });
app.use(Compress()); app.use(Compress());
app.use(async (ctx, next) => {
for (const key in captureAllRoutes) {
if (ctx.path.startsWith(key)) return captureAllRoutes[key](ctx, next);
}
return next();
});
for (const addon of [...global.addons].reverse()) { for (const addon of [...global.addons].reverse()) {
const dir = resolve(addon, 'public'); const dir = resolve(addon, 'public');
if (!fs.existsSync(dir)) continue; if (!fs.existsSync(dir)) continue;

@ -70,14 +70,11 @@ describe('App', () => {
} }
after(() => { after(() => {
const metrics = []; const metrics = Object.entries(([k, v]) => ({
for (const key in results) { name: `Benchmark - ${k} - Req/sec`,
metrics.push({ unit: 'Req/sec',
name: `Benchmark - ${key} - Req/sec`, value: v.requests.average,
unit: 'Req/sec', }));
value: results[key].requests.average,
});
}
writeFileSync('./benchmark.json', JSON.stringify(metrics, null, 2)); writeFileSync('./benchmark.json', JSON.stringify(metrics, null, 2));
setTimeout(() => process.exit(0), 1000); setTimeout(() => process.exit(0), 1000);
}); });

Loading…
Cancel
Save