forked from admin/deShanXiao
Compare commits
1 Commits
lxbfyeaa-p
...
lxbfyeaa-p
| Author | SHA1 | Date | |
|---|---|---|---|
| 0241d67d6a |
24
backEnd/index.ts
Normal file
24
backEnd/index.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
require("module-alias/register"); // 别名加载
|
||||||
|
|
||||||
|
import express from "express";
|
||||||
|
import bodyParser from "body-parser";
|
||||||
|
import routerIndex from "./src/router/index";
|
||||||
|
import { createConnection } from "typeorm";
|
||||||
|
import cors from "cors";
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const port = 8101;
|
||||||
|
createConnection().then(() => {
|
||||||
|
console.log("数据库连接成功!");
|
||||||
|
app.listen(port, () => {
|
||||||
|
console.log(`开始监听${port}了`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use(bodyParser.urlencoded({ extended: true })); // 进行url解码
|
||||||
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
|
app.use(cors());
|
||||||
|
|
||||||
|
// 匹配接口路由
|
||||||
|
app.use("/", routerIndex);
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": ["es5", "es6", "ES2022"],
|
|
||||||
"paths": {
|
|
||||||
"router/*": ["./src/router/*"],
|
|
||||||
"@/*": ["./src/*"]
|
|
||||||
},
|
|
||||||
"baseUrl": "./",
|
|
||||||
"declaration": true, // 是否生成.d.ts文件
|
|
||||||
"declarationDir": "./types", // .d.ts文件输出路径
|
|
||||||
"target": "ES5", // 编译目标
|
|
||||||
"module": "CommonJS",
|
|
||||||
// "strict": true,
|
|
||||||
"moduleResolution": "Node",
|
|
||||||
"outDir": "./build",
|
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"experimentalDecorators": true, // 用于指定是否启用实验性的装饰器特性
|
|
||||||
"sourceMap": false,
|
|
||||||
// "resolveJsonModule": true,
|
|
||||||
"allowSyntheticDefaultImports": true, // 用于允许从没有默认导出的模块中默认导入
|
|
||||||
"esModuleInterop": true, //是否允许export=导出,import from导入
|
|
||||||
},
|
|
||||||
// "ts-node": {
|
|
||||||
// "esm": true
|
|
||||||
// },
|
|
||||||
"include": ["src/**/*", "index.ts"]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user