feat: add bot and api services with config, logger and database packages
- Add bot service with telegram integration and webhook/polling modes - Add api service with hono, swagger and zod-openapi - Create config package for environment variable management - Create logger package for colored console logging - Create database package with prisma integration - Remove next.js web and docs apps - Update turbo.json for new services - Add dockerfiles and gitea workflows for deployment
This commit is contained in:
35
apps/api/src/index.ts
Normal file
35
apps/api/src/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
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',
|
||||
info: {
|
||||
version: '1.0.0',
|
||||
title: 'API Documentation',
|
||||
description: 'API built with Hono and Zod OpenAPI',
|
||||
},
|
||||
});
|
||||
|
||||
// Swagger UI
|
||||
app.get('/ui', swaggerUI({ url: '/doc' }));
|
||||
|
||||
// Health check
|
||||
app.get('/health', (c) => {
|
||||
return c.json({ status: 'ok', timestamp: new Date().toISOString() });
|
||||
});
|
||||
|
||||
const port = parseInt(config.PORT);
|
||||
|
||||
logger.info(`Starting API server on port ${port}`);
|
||||
logger.info(`Swagger UI available at http://localhost:${port}/ui`);
|
||||
|
||||
serve({
|
||||
fetch: app.fetch,
|
||||
port,
|
||||
});
|
||||
Reference in New Issue
Block a user