feat: add file storage service and update configurations
refactor: migrate to tsup for builds and update tsconfigs fix: update error handling and validation in payment service chore: update package scripts and dependencies docs: update README and env examples
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
import { serve } from '@hono/node-server';
|
||||
import { OpenAPIHono } from '@hono/zod-openapi';
|
||||
import { swaggerUI } from '@hono/swagger-ui';
|
||||
import { config } from './config';
|
||||
import { logger } from '@repo/logger';
|
||||
import { serve } from "@hono/node-server";
|
||||
import { OpenAPIHono } from "@hono/zod-openapi";
|
||||
import { swaggerUI } from "@hono/swagger-ui";
|
||||
import { config } from "./config";
|
||||
import { logger } from "@repo/logger";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
// OpenAPI documentation
|
||||
app.doc('/doc', {
|
||||
openapi: '3.0.0',
|
||||
app.doc("/doc", {
|
||||
openapi: "3.0.0",
|
||||
info: {
|
||||
version: '1.0.0',
|
||||
title: 'API Documentation',
|
||||
description: 'API built with Hono and Zod OpenAPI',
|
||||
version: "1.0.0",
|
||||
title: "API Documentation",
|
||||
description: "API built with Hono and Zod OpenAPI",
|
||||
},
|
||||
});
|
||||
|
||||
// Swagger UI
|
||||
app.get('/ui', swaggerUI({ url: '/doc' }));
|
||||
app.get("/ui", swaggerUI({ url: "/doc" }));
|
||||
|
||||
// Health check
|
||||
app.get('/health', (c) => {
|
||||
return c.json({ status: 'ok', timestamp: new Date().toISOString() });
|
||||
app.get("/health", (c) => {
|
||||
return c.json({ status: "ok", timestamp: new Date().toISOString() });
|
||||
});
|
||||
|
||||
const port = parseInt(config.PORT);
|
||||
@@ -29,7 +29,24 @@ const port = parseInt(config.PORT);
|
||||
logger.info(`Starting API server on port ${port}`);
|
||||
logger.info(`Swagger UI available at http://localhost:${port}/ui`);
|
||||
|
||||
serve({
|
||||
const server = serve({
|
||||
fetch: app.fetch,
|
||||
port,
|
||||
});
|
||||
|
||||
const tearDown = () => {
|
||||
logger.info("Server shutting down...");
|
||||
if (server) {
|
||||
server.close(() => {
|
||||
logger.info("Server closed");
|
||||
process.exit(0);
|
||||
});
|
||||
} else {
|
||||
process.exit(0);
|
||||
}
|
||||
};
|
||||
|
||||
process.on("SIGINT", tearDown);
|
||||
process.on("SIGTERM", tearDown);
|
||||
process.on("SIGUSR1", tearDown);
|
||||
process.on("SIGUSR2", tearDown);
|
||||
|
||||
Reference in New Issue
Block a user