Skip to content

Commit

Permalink
fix(pre-handlers): some issues of review feedbacks
Browse files Browse the repository at this point in the history
Co-authored-by: Ali Mihandoost <[email protected]>
  • Loading branch information
mohammadhonarvar and alimd committed Oct 28, 2024
1 parent 5f95120 commit 72ad94b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/pre-handlers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alwatr/pre-handlers",
"version": "1.0.0",
"version": "1.0.0-0",
"description": "Functions that will run before processing every defined route.",
"author": "S. Ali Mihandoost <[email protected]>",
"keywords": [
Expand Down Expand Up @@ -60,14 +60,14 @@
"clean": "rm -rfv dist *.tsbuildinfo"
},
"dependencies": {
"@alwatr/nanolib": "^1.3.0",
"@alwatr/nanotron-api-server": "workspace:^"
"@alwatr/nanolib": "^1.3.0"
},
"devDependencies": {
"@alwatr/nano-build": "^2.0.2",
"@alwatr/prettier-config": "^1.0.6",
"@alwatr/tsconfig-base": "^1.3.2",
"@alwatr/type-helper": "^2.0.2",
"@alwatr/nanotron-api-server": "workspace:^",
"@types/node": "^22.7.5",
"jest": "^29.7.0",
"typescript": "^5.6.3"
Expand Down
4 changes: 3 additions & 1 deletion packages/pre-handlers/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {createLogger} from '@alwatr/nanolib';
import {createLogger, packageTracer} from '@alwatr/nanolib';

__dev_mode__: packageTracer.add(__package_name__, __package_version__);

export const logger = /* #__PURE__ */ createLogger(__package_name__);
4 changes: 1 addition & 3 deletions packages/pre-handlers/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {packageTracer} from '@alwatr/nanolib';

export * from './parse-body-as-json.js';

__dev_mode__: packageTracer.add(__package_name__, __package_version__);

4 changes: 3 additions & 1 deletion packages/pre-handlers/src/parse-body-as-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export async function parseBodyAsJson(
this: NanotronClientRequest<{body: DictionaryOpt}>,
): Promise<void> {
const bodyBuffer = await this.getBodyRaw();
logger.logProperty?.('bodyBuffer', bodyBuffer);

if (bodyBuffer.length === 0) {
logger.error('parseBodyAsJson', 'body_required');
this.serverResponse.statusCode = HttpStatusCodes.Error_Client_422_Unprocessable_Entity;
Expand All @@ -32,5 +34,5 @@ export async function parseBodyAsJson(
});
}

logger.logMethodArgs?.('parseBodyAsJson', {body: this.sharedMeta.body});
logger.logProperty?.('body', this.sharedMeta.body);
}

0 comments on commit 72ad94b

Please sign in to comment.