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": {
"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"
}
}
}

View File

@ -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<string> {
})
}).then(res => res.json()) as BalabolaResponse;
logger.debug(result);
if (result.bad_query === 1) throw new BalabolaError('bad query');
return result.text;