koa2项目新看法 绝对正确的最佳路径

1、  
"scripts": {
    "dev": "ts-node-dev --respawn --transpile-only src/index.ts",
    "build": "tsc -p tsconfig.json",
    "start": "node dist/index.js"
  },
 
2、关于koa适配typeorm的情况
import { DataSource } from "typeorm";
import "dotenv/config";
import * as path from "path";

const entityExtension = __filename.endsWith(".ts") ? "ts" : "js";
export const PGsqlDataSource = new DataSource({
  type: "postgres",
  host: process.env.PGSQL_HOST,
  port: Number(process.env.PGSQL_PORT),
  username: process.env.PGSQL_USERNAME,
  password: process.env.PGSQL_PASSWORD,
  database: process.env.PGSQL_DATABASE,
  synchronize: false,
  entities: [path.join(__dirname, `../pgsqlentity/*.${entityExtension}`)],
  logging: true,
});

posted on 2026-07-21 15:12  漫思  阅读(10)  评论(0)    收藏  举报

导航