20 lines
546 B
JavaScript
20 lines
546 B
JavaScript
// ESM
|
|
import '#start';
|
|
import Fastify from 'fastify';
|
|
import config from '#config/index';
|
|
import plugin from '#src/plugins/index';
|
|
import routes from '#src/routes/index';
|
|
import logger from '#src/utils/logger';
|
|
|
|
async function start() {
|
|
// 创建Fastify实例
|
|
const fastify = new Fastify({ logger });
|
|
// 加载插件
|
|
await fastify.register(plugin, { config });
|
|
// 加载路由
|
|
await fastify.register(routes);
|
|
// 启动服务器
|
|
await fastify.listen(config.server); // 使用配置中的服务器参数
|
|
}
|
|
start();
|