Bootstrap REST API with TypeScript, Fastify, and Prisma for Node.js 24#1
Draft
Bootstrap REST API with TypeScript, Fastify, and Prisma for Node.js 24#1
Conversation
- Set up project structure with Node.js 24 configuration - Configure TypeScript, ESLint, and Prettier - Implement Fastify web framework with security plugins - Set up Prisma ORM with example schema - Create common folder with best practices: - config/ for app and database configuration - middleware/ for error handling - utils/ for database client and logger - types/ for shared TypeScript types - Implement health check endpoint with database connectivity check - Add proper folder structure: routes, services, controllers - Configure development and production scripts - Update README with comprehensive documentation Co-authored-by: alvinsw <2344573+alvinsw@users.noreply.github.com>
Co-authored-by: alvinsw <2344573+alvinsw@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Create a common folder for best practices in routes and services
Bootstrap REST API with TypeScript, Fastify, and Prisma for Node.js 24
Oct 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Initializes a production-ready REST API foundation using TypeScript, Fastify, and Prisma with clean architecture principles.
Structure
src/common/- Shared infrastructureconfig/- Environment-based configuration with explicit .env path resolutionmiddleware/- Centralized error handler with structured loggingtypes/- API response interfaces and pagination typesutils/- Prisma client singleton, Pino logger setupsrc/controllers/- Request/response handlerssrc/services/- Business logic layersrc/routes/- Fastify route definitions with schema validationImplementation
Health check endpoint demonstrating the pattern:
Configuration
Scripts
npm run dev- Hot reload with tsxnpm run build- TypeScript compilationnpm run lint- ESLint with Prettier integrationnpm run prisma:generate- Generate Prisma Clientnpm run prisma:migrate- Run migrationsEndpoints:
GET /(info),GET /api/v1/health(health check with DB connectivity)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
checkpoint.prisma.io/usr/local/bin/node /home/REDACTED/work/ldacapi/ldacapi/node_modules/prisma/build/child {"product":"prisma","version":"6.18.0","cli_install_type":"local","information":"","local_timestamp":"2025-10-29T01:24:05Z","project_hash":"811b365c","cli_path":"/home/REDACTED/work/ldacapi/ldacapi/node_modules/.bin/prisma","cli_path_hash":"fc09e426","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"generate --postinstall \"UNABLE_TO_FIND_POSTINSTALL_TRIGGER__ENVAR_MISSING\"","schema_providers":["postgresql"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-fc09e426","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/ldacapi/ldacapi/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true}(dns block)/usr/local/bin/node /home/REDACTED/work/ldacapi/ldacapi/node_modules/prisma/build/child {"product":"prisma","version":"6.18.0","cli_install_type":"local","information":"","local_timestamp":"2025-10-29T01:25:28Z","project_hash":"811b365c","cli_path":"/home/REDACTED/work/ldacapi/ldacapi/node_modules/.bin/prisma","cli_path_hash":"fc09e426","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"generate","schema_providers":["postgresql"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-fc09e426","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/ldacapi/ldacapi/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true}(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.