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:
Yuu Ottosoka
2025-07-12 16:01:57 +03:00
parent c0c04bbdba
commit f9ecac94f2
67 changed files with 3308 additions and 695 deletions

View File

@@ -1,10 +1,12 @@
import { createConfig } from '@repo/config';
import z from 'zod';
import 'dotenv/config';
import { createConfig } from "@repo/config";
import z from "zod";
import "dotenv/config";
export const config = createConfig({
schema: {
PORT: z.string().default('3001'),
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
PORT: z.string().default("3001"),
NODE_ENV: z
.enum(["development", "production", "test"])
.default("development"),
},
});
});

View File

@@ -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);