created new config lib
This commit is contained in:
parent
bc14acaeba
commit
68a4c2d550
36 changed files with 2681 additions and 134 deletions
7
apps/web-api/config/default.json
Normal file
7
apps/web-api/config/default.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"service": {
|
||||
"name": "web-api",
|
||||
"port": 4000,
|
||||
"environment": "development"
|
||||
}
|
||||
}
|
||||
|
|
@ -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": "*",
|
||||
|
|
|
|||
|
|
@ -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}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue