diff --git a/app/utils/env.server.ts b/app/utils/env.server.ts index 6ed4907..fc5745e 100644 --- a/app/utils/env.server.ts +++ b/app/utils/env.server.ts @@ -6,6 +6,7 @@ export type DbEngine = typeof supportedDbEngines[number]; const envVariables = z.object({ NODE_ENV: z.enum(['production', 'development', 'test']).optional(), + SHLINK_DASHBOARD_PORT: z.number().optional().default(3005), // Database connection options SHLINK_DASHBOARD_DB_DRIVER: z.enum(supportedDbEngines).optional(), diff --git a/server.ts b/server.ts index 86530b9..23e6881 100644 --- a/server.ts +++ b/server.ts @@ -1,10 +1,9 @@ import { createRequestHandler } from '@remix-run/express'; import express from 'express'; import { serverContainer } from './app/container/container.server'; +import { env, isProd } from './app/utils/env.server'; -const { NODE_ENV, SHLINK_DASHBOARD_PORT = '3005' } = process.env; - -const viteDevServer = NODE_ENV === 'production' +const viteDevServer = isProd() ? null : await import('vite').then( (vite) => @@ -30,6 +29,6 @@ app.use(serverContainer.emForkMiddleware); app.all('*', createRequestHandler({ build })); app.listen( - Number(SHLINK_DASHBOARD_PORT), - () => console.log(`App listening on http://localhost:${SHLINK_DASHBOARD_PORT}`), + env.SHLINK_DASHBOARD_PORT, + () => console.log(`App listening on http://localhost:${env.SHLINK_DASHBOARD_PORT}`), );