safety
This commit is contained in:
parent
879e9b4228
commit
c3cb36c8d6
51 changed files with 2290 additions and 1467 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { createHttpSecurity, httpSecurityOptions } from '@stock-bot/di';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import { initializeStockConfig } from '@stock-bot/stock-config';
|
||||
|
|
@ -7,6 +8,11 @@ import { getWebSocketHandler, type RunSocketData } from './websocket/run-updates
|
|||
|
||||
// Initialize configuration with service-specific overrides
|
||||
const config = initializeStockConfig('webApi');
|
||||
const security = createHttpSecurity({
|
||||
...httpSecurityOptions(),
|
||||
environment: config.environment,
|
||||
browserSessions: true,
|
||||
});
|
||||
|
||||
// Override queue settings for web-api (no workers needed)
|
||||
if (config.queue) {
|
||||
|
|
@ -17,7 +23,11 @@ if (config.queue) {
|
|||
|
||||
// Log the full configuration
|
||||
const logger = getLogger('web-api');
|
||||
logger.info('Service configuration:', config);
|
||||
logger.info('Service configuration:', {
|
||||
service: 'web-api',
|
||||
port: config.service.port,
|
||||
environment: config.environment,
|
||||
});
|
||||
|
||||
// Container factory function
|
||||
async function createContainer(config: import('@stock-bot/config').UnifiedAppConfig) {
|
||||
|
|
@ -56,10 +66,10 @@ export async function startServerWithWebSocket() {
|
|||
container = diContainer.resolve('serviceContainer');
|
||||
|
||||
// Create HTTP routes
|
||||
const routes = createRoutes(container);
|
||||
const routes = createRoutes(container, security);
|
||||
|
||||
// Create WebSocket route handler
|
||||
const wsRoute = createWebSocketRoute(container);
|
||||
const wsRoute = createWebSocketRoute(container, security);
|
||||
|
||||
// Start server with WebSocket support
|
||||
const port = config.service.port || 2003;
|
||||
|
|
@ -70,6 +80,8 @@ export async function startServerWithWebSocket() {
|
|||
try {
|
||||
server = Bun.serve<RunSocketData, {}>({
|
||||
port,
|
||||
hostname: security.hostname,
|
||||
maxRequestBodySize: 1_048_576,
|
||||
|
||||
// Handle HTTP requests
|
||||
async fetch(req, server) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue