feat(api): update health endpoint for OpenSheets Companion compatibility
- Add app name and version to health response - Rename 'service' to 'name' for better semantics - Rename 'error' to 'message' for consistency - Update documentation to reflect companion app usage
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
|
|
||||||
|
const APP_VERSION = "1.0.0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Health check endpoint para Docker e monitoring
|
* Health check endpoint para Docker, monitoring e OpenSheets Companion
|
||||||
* GET /api/health
|
* GET /api/health
|
||||||
*
|
*
|
||||||
* Retorna status 200 se a aplicação está saudável
|
* Retorna status 200 se a aplicação está saudável
|
||||||
* Verifica conexão com banco de dados
|
* Verifica conexão com banco de dados
|
||||||
|
* Usado pelo app Android para validar URL do servidor
|
||||||
*/
|
*/
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
@@ -17,8 +20,9 @@ export async function GET() {
|
|||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
status: "ok",
|
status: "ok",
|
||||||
|
name: "OpenSheets",
|
||||||
|
version: APP_VERSION,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
service: "opensheets-app",
|
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
@@ -29,9 +33,10 @@ export async function GET() {
|
|||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
status: "error",
|
status: "error",
|
||||||
|
name: "OpenSheets",
|
||||||
|
version: APP_VERSION,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
service: "opensheets-app",
|
message: error instanceof Error ? error.message : "Database connection failed",
|
||||||
error: error instanceof Error ? error.message : "Database connection failed",
|
|
||||||
},
|
},
|
||||||
{ status: 503 }
|
{ status: 503 }
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user