From bb8a0eb7617a6ee710d09f9dab383f19baa8173d Mon Sep 17 00:00:00 2001 From: xzeldon Date: Thu, 20 Oct 2022 20:12:31 +0300 Subject: [PATCH] debug log balabola output and bundle script --- package.json | 3 ++- src/balabola_api.ts | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 45909ca..8cf8add 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "nodemon", "build": "rm -rf ./dist && tsc --noEmit && NODE_ENV=production etsc", + "bundle": "npm run build && tar -czvf balabola.tar.gz .env -C dist .", "start": "node dist/index.js" }, "keywords": [], @@ -28,4 +29,4 @@ "nodemon": "^2.0.20", "typescript": "^4.8.4" } -} +} \ No newline at end of file diff --git a/src/balabola_api.ts b/src/balabola_api.ts index f6ea3ee..7637f48 100644 --- a/src/balabola_api.ts +++ b/src/balabola_api.ts @@ -1,4 +1,5 @@ import { fetch } from 'undici'; +import { logger } from './logger'; interface BalabolaResponse { bad_query: number, @@ -25,6 +26,8 @@ export async function balabola(query: string, intro: number): Promise { }) }).then(res => res.json()) as BalabolaResponse; + logger.debug(result); + if (result.bad_query === 1) throw new BalabolaError('bad query'); return result.text;