i just started new project and made only on route GET /tags it should query the DB (local postgres) using ORM (prisma) the return an array of strings but this error prevents the application from starting
### this is logs before the crash happens
>>[Nest] 25211 - 01/27/2023, 8:44:23 PM LOG [NestFactory] Starting Nest application...
[Nest] 25211 - 01/27/2023, 8:44:23 PM LOG [InstanceLoader] AppModule dependencies initialized +33ms
[Nest] 25211 - 01/27/2023, 8:44:23 PM LOG [InstanceLoader] TagModule dependencies initialized +1ms
[Nest] 25211 - 01/27/2023, 8:44:23 PM LOG [RoutesResolver] TagController {/api/tags}: +11ms
[Nest] 25211 - 01/27/2023, 8:44:23 PM LOG [RouterExplorer] Mapped {/api/tags, GET} route +4ms
Segmentation fault (core dumped)
the tag Service uses the prisma service which is same code from nest docs
//tag service
import { PrismaService } from '@app/prisma.service';
import { Injectable } from '@nestjs/common';
import { Tag } from '@prisma/client';
@Injectable()
export class TagService {
constructor(private readonly prisma: PrismaService) {}
async getAll(): Promise<Tag[]> {
return await this.prisma.tag.findMany();
}
}
//tag controller
import { Controller, Get } from '@nestjs/common';
import { TagService } from '@app/Tag/tag.service';
@Controller('tags')
export class TagController {
constructor(private readonly tagService: TagService) {}
@Get()
async getall(): Promise<{ tags: string[] }> {
const tags = await this.tagService.getAll();
return { tags: tags.map((t) => t.name) };
}
}
// tag module
import { Module } from '@nestjs/common';
import { TagController } from '@app/Tag/tag.controller';
import { TagService } from '@app/Tag/tag.service';
import { PrismaService } from '@app/prisma.service';
@Module({
controllers: [TagController],
providers: [TagService, PrismaService],
})
export class TagModule {}