feat: 创建数据库
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user