From 531b0b51f10374c4c91ddacd148ceb536b1aa527 Mon Sep 17 00:00:00 2001 From: nicetomytyuk Date: Mon, 22 Jul 2024 14:52:12 +0200 Subject: [PATCH] feat: Add basePath API friendly user response --- fly.toml | 4 ++-- src/app.ts | 1 + src/server/index.ts | 10 ++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fly.toml b/fly.toml index c4fc309..c3bae4f 100644 --- a/fly.toml +++ b/fly.toml @@ -18,9 +18,9 @@ NODE_ENV = "production" [http_service] internal_port = 3000 force_https = true - auto_stop_machines = false + auto_stop_machines = true auto_start_machines = true - min_machines_running = 0 + min_machines_running = 1 processes = ['app'] [[vm]] diff --git a/src/app.ts b/src/app.ts index 1ac128f..24f62b3 100644 --- a/src/app.ts +++ b/src/app.ts @@ -35,5 +35,6 @@ try { }); } } catch (error) { + console.log(error); process.exit(1); } diff --git a/src/server/index.ts b/src/server/index.ts index 5410ba1..ae8fd3c 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -1,18 +1,20 @@ -import { fastify } from "fastify"; +import Fastify from "fastify"; import { webhookCallback } from "grammy"; import { Bot } from "../bot/index.js"; import { config } from "../config.js"; export const createServer = async (bot: Bot) => { - const server = fastify(); + const server = Fastify({ + logger: true + }); server.setErrorHandler(async (error, request, response) => { await response.status(500).send({ error: "Oops! Something went wrong." }); }); server.get('/', async function handler (request, reply) { - return { success: true } - }) + return "Relaps bot is working!" + }); server.get(`/${bot.token}`, async (request, response) => { const hostname = request.headers["x-forwarded-host"];