Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/maybeanerd/booktracker. a multi platform application and server to track your book reading journey
hacktoberfest
Something went wrong. Try again.
12345678910111213141516171819202122232425262728import { Module } from '@nestjs/common';import { ConfigService } from '@nestjs/config';import { drizzle } from 'drizzle-orm/postgres-js';import postgres from 'postgres';import * as schema from './schema';
export const DB_CONNECTION = 'DB_CONNECTION';
@Module({ providers: [ { provide: DB_CONNECTION, inject: [ConfigService], useFactory: (configService: ConfigService) => { const connectionString = configService.get<string>( 'DATABASE_URL', 'postgresql://localhost:5432/booktracker', ); const client = postgres(connectionString); return drizzle(client, { schema }); }, }, ], exports: [DB_CONNECTION],})export class DbModule {}