Skip to content

Implement health check API endpoint and development SQLite override#12

Draft
Copilot wants to merge 3 commits intomain_oldfrom
copilot/fix-4982cb73-496a-4d8a-ab81-4e3f89b1c2bd
Draft

Implement health check API endpoint and development SQLite override#12
Copilot wants to merge 3 commits intomain_oldfrom
copilot/fix-4982cb73-496a-4d8a-ab81-4e3f89b1c2bd

Conversation

Copy link
Contributor

Copilot AI commented Aug 13, 2025

This PR implements a simplified health check API endpoint and introduces development SQLite override capabilities to streamline local development without impacting production MySQL usage.

Health Check API

Added a new Next.js App Router API route at /api/health that provides a lightweight database connectivity check:

// GET /api/health
{
  "ok": true,
  "uptime": 18.63,
  "responseTimeMs": 4,
  "timestamp": "2025-08-13T16:04:38.447Z",
  "db": { "status": "ok" }
}

The endpoint uses prisma.$queryRawSELECT 1`` to verify database connectivity and returns:

  • 200 OK with health status when database is reachable
  • 503 Service Unavailable with error details when database fails
  • Proper cache headers (Cache-Control: no-store) and dynamic = 'force-dynamic' for real-time monitoring

Development SQLite Override

Introduced a parallel development schema system that allows developers to use SQLite locally while maintaining MySQL for production:

New Development Schema: prisma/schema.dev.prisma

  • Duplicates all production models with SQLite provider
  • Removes MySQL-specific @db.* attributes for compatibility
  • Maintains identical model definitions for consistent TypeScript types

New Development Scripts:

npm run dev:sqlite           # Generate SQLite client + start dev server
npm run db:push:dev          # Push schema to SQLite database
npm run db:generate:dev      # Generate Prisma client for SQLite
npm run db:studio:dev        # Open Prisma Studio for SQLite
npm run db:reset:dev         # Reset SQLite database

Quick Setup: Developers can now run npm run db:push:dev && npm run dev:sqlite for instant local development without MySQL installation.

Documentation & Environment

  • .env.example: Comprehensive environment file with clear SQLite vs MySQL guidance
  • README Updates: Added detailed sections covering both development approaches
  • Developer Experience: One-command setup (npm run dev:sqlite) for SQLite development

Validation

✅ Health endpoint returns proper 200/503 responses with correct headers
✅ SQLite development workflow creates database and runs application successfully
✅ Production MySQL schema and behavior completely unchanged
✅ All builds pass with no new TypeScript or linting errors
✅ Comprehensive manual testing of all new workflows

This change significantly improves developer experience by eliminating the need for local MySQL setup while providing production-ready health monitoring capabilities.


💡 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.

Copilot AI and others added 2 commits August 13, 2025 16:05
Co-authored-by: syed-reza98 <71028588+syed-reza98@users.noreply.github.com>
Co-authored-by: syed-reza98 <71028588+syed-reza98@users.noreply.github.com>
Copilot AI changed the title [WIP] Add /api/health endpoint and development SQLite schema + scripts Implement health check API endpoint and development SQLite override Aug 13, 2025
Copilot AI requested a review from syed-reza98 August 13, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants