Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d28903c611 | |||
| a4f3ea7837 |
+3
-4
@@ -1,6 +1,5 @@
|
||||
# Core Server Configuration
|
||||
PORT=3000
|
||||
APP_PORT=3000
|
||||
API_KEY=your_secret_api_key_here
|
||||
|
||||
# Redis Configuration (Use redis://redis:6379 for Docker)
|
||||
REDIS_URL=redis://localhost:6379
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
|
||||
@@ -11,4 +11,7 @@ ENV NODE_ENV=production
|
||||
USER bun
|
||||
EXPOSE 3000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
||||
CMD bun -e "fetch('http://localhost:3000/health').then(res => res.ok ? process.exit(0) : process.exit(1)).catch(e => process.exit(1))"
|
||||
|
||||
CMD ["bun", "run", "start"]
|
||||
|
||||
+5
-8
@@ -3,22 +3,19 @@ services:
|
||||
build: .
|
||||
restart: always
|
||||
ports:
|
||||
- "${PORT:-3000}:3000"
|
||||
- "${APP_PORT:-3000}:3000"
|
||||
environment:
|
||||
- REDIS_URL=redis://redis:6379
|
||||
- REDIS_HOST=redis
|
||||
- REDIS_PORT=6379
|
||||
- API_KEY=${API_KEY}
|
||||
depends_on:
|
||||
- redis
|
||||
healthcheck:
|
||||
test: [ "CMD", "bun", "-e", "fetch('http://localhost:3000/health').then(res => res.ok ? process.exit(0) : process.exit(1)).catch(e => process.exit(1))" ]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
redis:
|
||||
image: redis:alpine
|
||||
restart: always
|
||||
ports:
|
||||
- "${REDIS_PORT:-6379}:6379"
|
||||
volumes:
|
||||
- redis-data:/data
|
||||
|
||||
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const configSchema = z.object({
|
||||
PORT: z.string().default("3000"),
|
||||
REDIS_URL: z.string(),
|
||||
APP_PORT: z.string().default("3000"),
|
||||
REDIS_HOST: z.string().default("redis"),
|
||||
REDIS_PORT: z.coerce.number().default(6379),
|
||||
API_KEY: z.string(),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { Redis } from "ioredis";
|
||||
import { config } from "../config";
|
||||
|
||||
export const redis = new Redis(config.REDIS_URL);
|
||||
export const redis = new Redis({
|
||||
host: config.REDIS_HOST,
|
||||
port: config.REDIS_PORT,
|
||||
});
|
||||
|
||||
+1
-1
@@ -74,6 +74,6 @@ app.get("/health", async (c) => {
|
||||
export { app };
|
||||
|
||||
export default {
|
||||
port: Number.parseInt(config.PORT, 10),
|
||||
port: Number.parseInt(config.APP_PORT, 10),
|
||||
fetch: app.fetch,
|
||||
};
|
||||
|
||||
+3
-2
@@ -2,8 +2,9 @@ import { mock } from "bun:test";
|
||||
|
||||
// Global test setup to stub environment variables
|
||||
process.env.API_KEY = "test-api-key";
|
||||
process.env.REDIS_URL = "redis://localhost:6379";
|
||||
process.env.PORT = "3000";
|
||||
process.env.REDIS_HOST = "localhost";
|
||||
process.env.REDIS_PORT = "6379";
|
||||
process.env.APP_PORT = "3000";
|
||||
|
||||
// Global Redis mock
|
||||
mock.module("../src/core/RedisClient", () => ({
|
||||
|
||||
Reference in New Issue
Block a user