feat: add initial project configuration and smoke tests
- Created pnpm workspace configuration to manage packages. - Added a placeholder .gitkeep file in the scripts directory. - Implemented a smoke test script to validate core API and web endpoints. - Established TypeScript base configuration for consistent compilation settings. - Introduced Turbo configuration for task management and build processes.
This commit is contained in:
33
packages/api/src/prisma/prisma.service.ts
Normal file
33
packages/api/src/prisma/prisma.service.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { PrismaClient } from '../generated/prisma/client';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
|
||||
/**
|
||||
* NestJS-managed Prisma service for Prisma 7.
|
||||
*
|
||||
* Follows the official NestJS + Prisma 7 recipe:
|
||||
* - Uses `prisma-client` generator with `moduleFormat = "cjs"`
|
||||
* - Extends PrismaClient directly for full type-safe API access
|
||||
* - Uses PrismaPg driver adapter with connectionString
|
||||
*
|
||||
* Usage in feature modules:
|
||||
* constructor(private readonly prisma: PrismaService) {}
|
||||
* await this.prisma.placeholder.findMany();
|
||||
*/
|
||||
@Injectable()
|
||||
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
||||
constructor(configService: ConfigService) {
|
||||
const databaseUrl = configService.getOrThrow<string>('DATABASE_URL');
|
||||
const adapter = new PrismaPg({ connectionString: databaseUrl });
|
||||
super({ adapter });
|
||||
}
|
||||
|
||||
async onModuleInit(): Promise<void> {
|
||||
await this.$connect();
|
||||
}
|
||||
|
||||
async onModuleDestroy(): Promise<void> {
|
||||
await this.$disconnect();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user