feat: 初始化项目结构并添加基本功能

- 新增 .env 文件,配置服务器端口
- 添加 nodemon 作为开发依赖
- 创建服务器入口文件,设置基本路由
- 移除旧的服务器代码
- 更新 package.json,添加启动脚本
This commit is contained in:
2025-04-24 12:12:29 +08:00
parent 9db06fa737
commit 7a7d390682
5 changed files with 356 additions and 16 deletions

15
server/index.js Normal file
View File

@@ -0,0 +1,15 @@
// 引入 dotenv 并加载 .env 文件
require('dotenv').config();
const express = require("express");
const roleRoutes = require("./src/routes/role.routes");
const app = express();
const port = process.env.SERVER_PORT || 3000; // 使用环境变量中的端口号
// 注册路由
app.use("/api", roleRoutes);
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});

View File

@@ -1,12 +0,0 @@
const express = require('express');
const roleRoutes = require('./routes/role.routes');
const app = express();
const port = 3000;
// 注册路由
app.use('/api', roleRoutes);
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});