1 Star 0 Fork 0

LanYun/NodeJS接口服务项目模板

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.ts 743 Bytes
一键复制 编辑 原始数据 按行查看 历史
LanYun 提交于 2024-08-20 20:57 +08:00 . first
import '@/models/init';
import dotenv from 'dotenv';
import { exp } from '@/express';
import sequelize from '@/models';
import { error } from '@/utils/u.logger';
dotenv.config();
const port: number = Number(process.env.SERVER_PORT) || 3000;
async function bootstrap(): Promise<void> {
try {
// 测试连接数据库
await sequelize.authenticate();
// 同步数据模型
await sequelize.sync({ alter: true });
console.log('😃 数据库连接成功');
// 启动接口服务
exp.listen(port || 3000, (): void => {
console.log(`🚀 接口服务启动成功,运行在:http://localhost:${port}`);
});
} catch (err: any) {
console.error('😅 数据库连接失败:', err.message);
error(err);
}
}
bootstrap();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lanyun417/nodeservertemplate.git
[email protected]:lanyun417/nodeservertemplate.git
lanyun417
nodeservertemplate
NodeJS接口服务项目模板
master

搜索帮助