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,2 +1,3 @@
|
||||
PORT=3001
|
||||
NODE_ENV=development
|
||||
NODE_ENV=development
|
||||
DATABASE_URL=copy from packages/database/.env
|
||||
@@ -1,2 +1,3 @@
|
||||
# `api`
|
||||
Апи клиент
|
||||
|
||||
Апи клиент
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
"name": "api",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "NODE_PATH=./src tsnd --respawn --transpile-only --exit-child src/index.ts",
|
||||
"build": "tsc",
|
||||
"start": "NODE_PATH=./dist node ./dist/index.js"
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"build": "tsup",
|
||||
"start": "node dist/index.js",
|
||||
"check-types": "tsc --noEmit",
|
||||
"clean": "rm -rf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hono/node-server": "^1.15.0",
|
||||
@@ -22,7 +25,9 @@
|
||||
"zod-openapi": "^4.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"typescript": "latest"
|
||||
"@types/node": "^22.10.2",
|
||||
"tsup": "^8.3.5",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
{
|
||||
"extends": "@repo/typescript-config/base.json",
|
||||
"extends": "@repo/typescript-config/node.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"rootDir": "src"
|
||||
"rootDir": ".",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
"include": ["src/**/*"],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"**/*.test.*",
|
||||
"**/*.spec.*"
|
||||
]
|
||||
}
|
||||
1
apps/api/tsconfig.tsbuildinfo
Normal file
1
apps/api/tsconfig.tsbuildinfo
Normal file
File diff suppressed because one or more lines are too long
15
apps/api/tsup.config.ts
Normal file
15
apps/api/tsup.config.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
export default defineConfig({
|
||||
entry: ["src/index.ts"],
|
||||
format: ["esm"],
|
||||
dts: false,
|
||||
splitting: false,
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
external: ["@repo/config", "@repo/logger", "@repo/typescript-config"],
|
||||
treeshake: true,
|
||||
minify: false,
|
||||
target: "node18",
|
||||
platform: "node",
|
||||
});
|
||||
Reference in New Issue
Block a user