created new config lib

This commit is contained in:
Boki 2025-06-18 14:01:45 -04:00
parent bc14acaeba
commit 68a4c2d550
36 changed files with 2681 additions and 134 deletions

View file

@ -0,0 +1,7 @@
{
"service": {
"name": "web-api",
"port": 4000,
"environment": "development"
}
}

View file

@ -12,7 +12,7 @@
"clean": "rm -rf dist"
},
"dependencies": {
"@stock-bot/config": "*",
"@stock-bot/config-new": "*",
"@stock-bot/logger": "*",
"@stock-bot/mongodb-client": "*",
"@stock-bot/postgres-client": "*",

View file

@ -3,7 +3,7 @@
*/
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import { loadEnvVariables } from '@stock-bot/config';
import { initializeConfig, getServiceConfig } from '@stock-bot/config-new';
import { getLogger, shutdownLoggers } from '@stock-bot/logger';
import { connectMongoDB, disconnectMongoDB } from '@stock-bot/mongodb-client';
import { connectPostgreSQL, disconnectPostgreSQL } from '@stock-bot/postgres-client';
@ -12,8 +12,8 @@ import { Shutdown } from '@stock-bot/shutdown';
import { exchangeRoutes } from './routes/exchange.routes';
import { healthRoutes } from './routes/health.routes';
// Load environment variables
loadEnvVariables();
// Initialize configuration
await initializeConfig();
const app = new Hono();
@ -29,7 +29,8 @@ app.use(
);
const logger = getLogger('web-api');
const PORT = parseInt(process.env.WEB_API_PORT || '4000');
const serviceConfig = getServiceConfig();
const PORT = serviceConfig.port;
let server: ReturnType<typeof Bun.serve> | null = null;
// Initialize shutdown manager
@ -82,7 +83,7 @@ async function startServer() {
server = Bun.serve({
port: PORT,
fetch: app.fetch,
development: process.env.NODE_ENV === 'development',
development: serviceConfig.environment === 'development',
});
logger.info(`Stock Bot Web API started on port ${PORT}`);