debug log balabola output and bundle script

This commit is contained in:
Timofey Gelazoniya 2022-10-20 20:12:31 +03:00
parent 3025421e34
commit bb8a0eb761
Signed by: zeldon
GPG Key ID: 047886915281DD2A
2 changed files with 5 additions and 1 deletions

View File

@ -6,6 +6,7 @@
"scripts": { "scripts": {
"dev": "nodemon", "dev": "nodemon",
"build": "rm -rf ./dist && tsc --noEmit && NODE_ENV=production etsc", "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" "start": "node dist/index.js"
}, },
"keywords": [], "keywords": [],

View File

@ -1,4 +1,5 @@
import { fetch } from 'undici'; import { fetch } from 'undici';
import { logger } from './logger';
interface BalabolaResponse { interface BalabolaResponse {
bad_query: number, bad_query: number,
@ -25,6 +26,8 @@ export async function balabola(query: string, intro: number): Promise<string> {
}) })
}).then(res => res.json()) as BalabolaResponse; }).then(res => res.json()) as BalabolaResponse;
logger.debug(result);
if (result.bad_query === 1) throw new BalabolaError('bad query'); if (result.bad_query === 1) throw new BalabolaError('bad query');
return result.text; return result.text;