feat: 创建数据库

This commit is contained in:
R524809
2026-10-12 16:56:42 +08:00
parent 3c6fd2c8ca
commit 63a6993276
35 changed files with 826 additions and 266 deletions
+18 -18
View File
@@ -1,27 +1,27 @@
export interface RuntimeOptions {
host: string;
port: number;
host: string;
port: number;
}
export function getRuntimeOptions(
env: NodeJS.ProcessEnv = process.env,
env: NodeJS.ProcessEnv = process.env,
): RuntimeOptions {
const rawPort = env.PORT ?? '3000';
const port = Number(rawPort);
const host = (env.HOST ?? '127.0.0.1').trim();
const rawPort = env.PORT ?? '3000';
const port = Number(rawPort);
const host = (env.HOST ?? '127.0.0.1').trim();
if (
!/^\d+$/.test(rawPort) ||
!Number.isInteger(port) ||
port < 1 ||
port > 65535
) {
throw new Error('PORT must be an integer between 1 and 65535');
}
if (
!/^\d+$/.test(rawPort) ||
!Number.isInteger(port) ||
port < 1 ||
port > 65535
) {
throw new Error('PORT must be an integer between 1 and 65535');
}
if (!host) {
throw new Error('HOST must not be empty');
}
if (!host) {
throw new Error('HOST must not be empty');
}
return { host, port };
return { host, port };
}