feat: 初始化项目

This commit is contained in:
R524809
2026-10-12 15:22:27 +08:00
commit 3c6fd2c8ca
37 changed files with 4859 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
export interface RuntimeOptions {
host: string;
port: number;
}
export function getRuntimeOptions(
env: NodeJS.ProcessEnv = process.env,
): RuntimeOptions {
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 (!host) {
throw new Error('HOST must not be empty');
}
return { host, port };
}