Embed base images into binary
Include resource directory Ran `deno fmt` with 4 space indent, that changed every file (!!!!!) various changes
This commit is contained in:
59
src/main.ts
59
src/main.ts
@@ -15,16 +15,20 @@ log.i(`Starting Galvanic Corrosion..`);
|
||||
|
||||
const config = Config.getConfig();
|
||||
|
||||
if (typeof config == 'undefined') {
|
||||
log.e('Cannot start: Configuration is undefined');
|
||||
if (typeof config == "undefined") {
|
||||
log.e("Cannot start: Configuration is undefined");
|
||||
Deno.exit(1);
|
||||
}
|
||||
if (config.auth.secret == Config.defaultConfig.auth.secret) {
|
||||
log.e(`Cannot start: Auth secret is default. Please change 'secrets.authSecret' in 'config.json'`);
|
||||
log.e(
|
||||
`Cannot start: Auth secret is default. Please change 'secrets.authSecret' in 'config.json'`,
|
||||
);
|
||||
Deno.exit(1);
|
||||
}
|
||||
if (config.public.serverId == Config.defaultConfig.public.serverId) {
|
||||
log.e(`Cannot start: Server ID is default. Please change 'public.serverId' in 'config.json'`);
|
||||
log.e(
|
||||
`Cannot start: Server ID is default. Please change 'public.serverId' in 'config.json'`,
|
||||
);
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
@@ -45,41 +49,52 @@ log.n(`Starting HTTP server on http://${host}:${port}`);
|
||||
|
||||
const app = express();
|
||||
|
||||
app.disable('etag');
|
||||
app.disable('x-powered-by');
|
||||
app.disable("etag");
|
||||
app.disable("x-powered-by");
|
||||
|
||||
app.use((rq: express.Request, rs: express.Response, nxt: express.NextFunction) => {
|
||||
rs.setHeader('Instance', instanceId)
|
||||
log.n(`${APIUtils.getSrcIpDefault(rq)} ${rq.method} ${rq.originalUrl}`);
|
||||
nxt();
|
||||
});
|
||||
app.use(
|
||||
(rq: express.Request, rs: express.Response, nxt: express.NextFunction) => {
|
||||
rs.setHeader("Instance", instanceId);
|
||||
log.n(`${APIUtils.getSrcIpDefault(rq)} ${rq.method} ${rq.originalUrl}`);
|
||||
nxt();
|
||||
},
|
||||
);
|
||||
|
||||
app.get('/info', (_rq, rs) => {
|
||||
app.get("/info", (_rq, rs) => {
|
||||
rs.json({
|
||||
name: config.public.serverName,
|
||||
id: config.public.serverId,
|
||||
motd: config.public.motd,
|
||||
patches: config.public.patches
|
||||
patches: config.public.patches,
|
||||
});
|
||||
});
|
||||
|
||||
// content routes
|
||||
const nameserverRouter = await import('./routes/nameserver.ts');
|
||||
const apiRouter = await import('./routes/api.ts');
|
||||
const userRouter = await import('./routes/user.ts');
|
||||
const authRouter = await import('./routes/auth.ts');
|
||||
const accountRouter = await import('./routes/account.ts');
|
||||
const nameserverRouter = await import("./routes/nameserver.ts");
|
||||
const apiRouter = await import("./routes/api.ts");
|
||||
const userRouter = await import("./routes/user.ts");
|
||||
const authRouter = await import("./routes/auth.ts");
|
||||
const accountRouter = await import("./routes/account.ts");
|
||||
const imgRouter = await import("./routes/img.ts");
|
||||
|
||||
app.use(nameserverRouter.route.path, nameserverRouter.route.router);
|
||||
app.use(apiRouter.route.path, apiRouter.route.router);
|
||||
app.use(userRouter.route.path, userRouter.route.router);
|
||||
app.use(authRouter.route.path, authRouter.route.router);
|
||||
app.use(accountRouter.route.path, accountRouter.route.router);
|
||||
app.use(imgRouter.route.path, imgRouter.route.router);
|
||||
|
||||
app.use((rq: express.Request, rs: express.Response) => {
|
||||
log.e(`${APIUtils.getSrcIpDefault(rq)} 404 ${rq.method} ${rq.url.toString()}`);
|
||||
log.e(
|
||||
`${APIUtils.getSrcIpDefault(rq)} 404 ${rq.method} ${rq.url.toString()}`,
|
||||
);
|
||||
rs.statusCode = 404;
|
||||
rs.json(APIUtils.genericResponseFormat(true, 'Endpoint not found. Check your syntax and/or method.'));
|
||||
rs.json(
|
||||
APIUtils.genericResponseFormat(
|
||||
true,
|
||||
"Endpoint not found. Check your syntax and/or method.",
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -87,7 +102,7 @@ try {
|
||||
log.n(`Listening on http://${config.web.host}:${config.web.port}`);
|
||||
|
||||
let shuttingDown = false;
|
||||
Deno.addSignalListener('SIGINT', () => {
|
||||
Deno.addSignalListener("SIGINT", () => {
|
||||
if (shuttingDown) return;
|
||||
shuttingDown = true;
|
||||
log.i(`Shutting down`);
|
||||
@@ -100,4 +115,4 @@ try {
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
Discord.login();
|
||||
Discord.login();
|
||||
|
||||
Reference in New Issue
Block a user