mirror of
https://github.com/aditama-labs/nest-autocrud.git
synced 2024-11-22 03:16:21 +00:00
wip: get database credential by single env that also used by prisma
This commit is contained in:
parent
fb87cc03af
commit
ea551f8730
@ -33,7 +33,7 @@ import {
|
|||||||
ISkeletonPaginationController,
|
ISkeletonPaginationController,
|
||||||
ISkeletonReadController,
|
ISkeletonReadController,
|
||||||
ISkeletonUpdateController,
|
ISkeletonUpdateController,
|
||||||
} from './interfaces/controller/skeleton-crud.controller.interface';
|
} from '@aditama-labs/nest-autocrud/skeleton/src/interfaces';
|
||||||
|
|
||||||
export class SkeletonDetailController implements ISkeletonReadController {
|
export class SkeletonDetailController implements ISkeletonReadController {
|
||||||
constructor(
|
constructor(
|
||||||
|
595
package-lock.json
generated
595
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -35,12 +35,15 @@
|
|||||||
"@nestjs/common": "^10.0.0",
|
"@nestjs/common": "^10.0.0",
|
||||||
"@nestjs/core": "^10.0.0",
|
"@nestjs/core": "^10.0.0",
|
||||||
"@nestjs/platform-express": "^10.0.0",
|
"@nestjs/platform-express": "^10.0.0",
|
||||||
|
"@nestjs/typeorm": "^10.0.2",
|
||||||
"@prisma/client": "^5.21.1",
|
"@prisma/client": "^5.21.1",
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.1",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
|
"pg": "^8.13.1",
|
||||||
"reflect-metadata": "^0.2.0",
|
"reflect-metadata": "^0.2.0",
|
||||||
"rxjs": "^7.8.1"
|
"rxjs": "^7.8.1",
|
||||||
|
"typeorm": "^0.3.20"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nestjs/cli": "^10.0.0",
|
"@nestjs/cli": "^10.0.0",
|
||||||
|
@ -1,9 +1,35 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { SimpleModule } from './example/simple/simple.module';
|
import { SimpleModule } from './example/simple/simple.module';
|
||||||
import { CustomModule } from './example/custom/custom.module';
|
import { CustomModule } from './example/custom/custom.module';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
|
||||||
|
const getDatabaseCredential = (): any => {
|
||||||
|
const url = new URL(process.env.DATABASE_URL);
|
||||||
|
|
||||||
|
// Extract the necessary components
|
||||||
|
const username = url.username;
|
||||||
|
const password = url.password;
|
||||||
|
const host = url.hostname;
|
||||||
|
const port = url.port;
|
||||||
|
const databaseName = url.pathname.substring(1); // Remove the leading slash
|
||||||
|
return {
|
||||||
|
type: 'postgres',
|
||||||
|
host: host,
|
||||||
|
port: port,
|
||||||
|
username: username,
|
||||||
|
password: password,
|
||||||
|
database: databaseName,
|
||||||
|
entities: [],
|
||||||
|
synchronize: true,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [SimpleModule, CustomModule],
|
imports: [
|
||||||
|
SimpleModule,
|
||||||
|
CustomModule,
|
||||||
|
TypeOrmModule.forRoot(getDatabaseCredential()),
|
||||||
|
],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
providers: [],
|
providers: [],
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user