fix app.ts database to AppDataSource
This commit is contained in:
parent
f7db1ed888
commit
d7926538ae
3 changed files with 6 additions and 6 deletions
|
|
@ -5,11 +5,11 @@ import express from "express";
|
|||
import swaggerUi from "swagger-ui-express";
|
||||
import swaggerDocument from "./swagger.json";
|
||||
import error from "./middlewares/error";
|
||||
import database from "./database/data-source";
|
||||
import { AppDataSource } from "./database/data-source";
|
||||
import { RegisterRoutes } from "./routes";
|
||||
|
||||
async function main() {
|
||||
// await database.initialize();
|
||||
await AppDataSource.initialize();
|
||||
|
||||
const app = express();
|
||||
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ import {
|
|||
Example,
|
||||
} from "tsoa";
|
||||
import { CreateOrgRoot, OrgRoot } from "../entities/OrgRoot";
|
||||
import database from "../database/data-source";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
|
||||
@Route("organization")
|
||||
@Tags("OrgRoot")
|
||||
// @Security("bearerAuth")
|
||||
export class OrgRootController extends Controller {
|
||||
private orgRootRepository = database.getRepository(OrgRoot);
|
||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||
|
||||
/**
|
||||
* สร้างโครงสร้างระดับ Root
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import "dotenv/config";
|
|||
import "reflect-metadata";
|
||||
import { DataSource } from "typeorm";
|
||||
|
||||
const database = new DataSource({
|
||||
export const AppDataSource = new DataSource({
|
||||
type: "mysql",
|
||||
database: process.env.DB_NAME,
|
||||
host: process.env.DB_HOST,
|
||||
|
|
@ -16,4 +16,4 @@ const database = new DataSource({
|
|||
subscribers: [],
|
||||
});
|
||||
|
||||
export default database;
|
||||
// export default database;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue