diff --git a/compose.yml b/compose.yml index cf26eda..74d98bb 100644 --- a/compose.yml +++ b/compose.yml @@ -28,7 +28,8 @@ services: fe-middleware: image: oven/bun:1 container_name: fe-middleware - command: bun run docker-dev + entrypoint: /bin/bash -c + command: ["bun --hot run src/index.ts"] working_dir: /usr/src/app ports: - "8081:8081" diff --git a/package.json b/package.json index 1090331..fa23b98 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,7 @@ }, "scripts": { "start": "bun run src/index.ts", - "docker-dev": "bun --hot run src/index.ts", "dev": "docker compose down -v && docker compose up", - "test": "docker compose down -v && docker compose run fe-middleware bun test" + "test": "docker compose down -v && docker compose run fe-middleware 'sleep 5 && bun test'" } } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 08056df..d9ebac5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,13 @@ import app from "./app"; const PORT = env.PORT; -app.listen(PORT, () => +const server = app.listen(PORT, () => console.log(`Express server listening on port ${PORT}`) -); \ No newline at end of file +); + +process.on("SIGTERM", (code) => { + server.close(() => { + console.log('Server closed.'); + process.exit(0); + }); +}); \ No newline at end of file diff --git a/src/services/BotApiService.ts b/src/services/BotApiService.ts index b932b7d..4b4f4a1 100644 --- a/src/services/BotApiService.ts +++ b/src/services/BotApiService.ts @@ -6,7 +6,6 @@ class BotApiService { async getAll(): Promise { const get_url = `${this.BOT_API_URI}/images`; - console.log(`Connecting to "${get_url}"...`) const response: BotApiResponse = await fetch(get_url) .then(res => { if (!res.ok) { diff --git a/test/ImageController/ImageController.test.ts b/test/ImageController/ImageController.test.ts index 41a0d31..52b9da9 100644 --- a/test/ImageController/ImageController.test.ts +++ b/test/ImageController/ImageController.test.ts @@ -27,7 +27,6 @@ describe("endpoint returns the correct status codes", () => { it("should return 500 if any error happens", async () => { mock.module("../../src/services/ImageService", () => { - let alreadyCalled = false; return { default: { get: () => {