统一前后端代码格式化配置

This commit is contained in:
yml2213
2026-08-16 17:27:12 +08:00
parent 8705f6a6a1
commit 5c7c3e14e3
278 changed files with 6386 additions and 5500 deletions
+37 -43
View File
@@ -1,69 +1,63 @@
import process from "node:process";
import process from 'node:process'
import { createApp } from "./app.js";
import { runtimeConfig } from "./config/runtime.js";
import { assertRuntimeConfigValid } from "./config/runtime-validation.js";
import { bootstrapCoreServices } from "./startup/bootstrap.js";
import { createShutdownController } from "./startup/shutdown.js";
import { createStartupState, formatStartupError } from "./startup/state.js";
import { logError, logInfo } from "./utils/logger.js";
import { createApp } from './app.js'
import { runtimeConfig } from './config/runtime.js'
import { assertRuntimeConfigValid } from './config/runtime-validation.js'
import { bootstrapCoreServices } from './startup/bootstrap.js'
import { createShutdownController } from './startup/shutdown.js'
import { createStartupState, formatStartupError } from './startup/state.js'
import { logError, logInfo } from './utils/logger.js'
const port = Number(runtimeConfig.server.port || 3000);
const host = "0.0.0.0";
const startupState = createStartupState();
const port = Number(runtimeConfig.server.port || 3000)
const host = '0.0.0.0'
const startupState = createStartupState()
let shutdownController: ReturnType<typeof createShutdownController> | null = null;
let shutdownController: ReturnType<typeof createShutdownController> | null = null
try {
assertRuntimeConfigValid(runtimeConfig);
assertRuntimeConfigValid(runtimeConfig)
} catch (error) {
logError("[startup]", "运行时配置校验失败,服务停止启动", error);
process.exit(1);
logError('[startup]', '运行时配置校验失败,服务停止启动', error)
process.exit(1)
}
const app = createApp({
startupState,
isShutdownStarted: () => shutdownController?.isShutdownStarted() || false,
config: runtimeConfig,
});
})
const server = app.listen(port, host, () => {
logInfo(
"[startup]",
`order-site-backend kuaishou-lite listening on http://${host}:${port}`
);
void bootstrapCoreServices(
startupState,
() => shutdownController?.isShutdownStarted() || false
);
});
logInfo('[startup]', `order-site-backend kuaishou-lite listening on http://${host}:${port}`)
void bootstrapCoreServices(startupState, () => shutdownController?.isShutdownStarted() || false)
})
shutdownController = createShutdownController(server, startupState);
shutdownController = createShutdownController(server, startupState)
server.on("error", (error) => {
logError("[startup]", "HTTP server failed", error);
});
server.on('error', (error) => {
logError('[startup]', 'HTTP server failed', error)
})
process.on("SIGINT", () => {
void shutdownController?.shutdown("SIGINT");
});
process.on('SIGINT', () => {
void shutdownController?.shutdown('SIGINT')
})
process.on("SIGTERM", () => {
void shutdownController?.shutdown("SIGTERM");
});
process.on('SIGTERM', () => {
void shutdownController?.shutdown('SIGTERM')
})
process.on("unhandledRejection", (reason) => {
process.on('unhandledRejection', (reason) => {
startupState.process.lastUnhandledRejection = {
time: new Date().toISOString(),
message: formatStartupError(reason),
};
logError("[process]", "unhandled promise rejection", reason);
});
}
logError('[process]', 'unhandled promise rejection', reason)
})
process.on("uncaughtException", (error) => {
process.on('uncaughtException', (error) => {
startupState.process.lastUncaughtException = {
time: new Date().toISOString(),
message: formatStartupError(error),
};
logError("[process]", "uncaught exception captured", error);
});
}
logError('[process]', 'uncaught exception captured', error)
})