Node.js framework NestJS project for performance
If you focus on the performance or features of the module, you can consider using another module as an alternative in NestJS.
In this example, the changed modules are as follows.
- Fastify instead of
Express
- Prisma with nestjs-prisma instead of
TypeORM
- SWC instead of
TypeScript compiler
- Vitest with vitest-mock-extended instead of
Jest
- Create a
.env
file- Rename the .env.sample file to
.env
to fix it.
- Rename the .env.sample file to
- Edit the schema.prisma file.
# 1. node_modules
npm ci
# 2-1. Generate schema from existing database
npx prisma db pull
# Convert snake_case to PascalCase, camelCase in the generated schema
npx @paljs/cli schema camel-case
# 2-2. Write a model and generate it in the database (one of the following)
npx prisma db push
npx prisma migrate dev
# 3. Apply schema model to @prisma/client
npx prisma generate
npm run start:dev
npm test # exclude e2e
npm run test:e2e # only e2e
# define NODE_ENV and PORT
npm run build
# NODE_ENV=production PORT=8000 node dist/app
node dist/app
# OR
npm start