@alwatr/pre-handlers 4.10.0 โ 4.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/main.cjs +2 -2
- package/dist/main.mjs +2 -2
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.10.1](https://github.com/Alwatr/pre-handlers/compare/v4.10.0...v4.10.1) (2025-09-21)
|
|
7
|
+
|
|
8
|
+
### ๐งน Miscellaneous Chores
|
|
9
|
+
|
|
10
|
+
* add "sideEffects": false to package.json files for better tree-shaking ([2aae07b](https://github.com/Alwatr/pre-handlers/commit/2aae07b0e1757b6035ea0ca8c1b0eda64a13dfcc))
|
|
11
|
+
|
|
6
12
|
## [4.10.0](https://github.com/Alwatr/pre-handlers/compare/v4.9.4...v4.10.0) (2025-09-21)
|
|
7
13
|
|
|
8
14
|
### ๐ Bug Fixes
|
package/dist/main.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** ๐ฆ @alwatr/pre-handlers v4.10.
|
|
2
|
-
__dev_mode__: console.debug("๐ฆ @alwatr/pre-handlers v4.10.
|
|
1
|
+
/** ๐ฆ @alwatr/pre-handlers v4.10.1 */
|
|
2
|
+
__dev_mode__: console.debug("๐ฆ @alwatr/pre-handlers v4.10.1");
|
|
3
3
|
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{getAuthBearer:()=>getAuthBearer,parseBodyAsJson:()=>parseBodyAsJson,requireAccessToken:()=>requireAccessToken});module.exports=__toCommonJS(main_exports);function getAuthBearer(authorizationHeader){const auth=authorizationHeader?.split(" ");if(!auth||auth[0].toLowerCase()!=="bearer"||!auth[1]){return null}return auth[1]}var import_nanotron_api_server=require("@alwatr/nanotron-api-server");async function parseBodyAsJson(){this.logger_.logMethod?.("parseBodyAsJson");const bodyBuffer=await this.getBodyRaw();if(bodyBuffer.length===0){this.logger_.error("parseBodyAsJson","body_required");this.serverResponse.statusCode=import_nanotron_api_server.HttpStatusCodes.Error_Client_422_Unprocessable_Entity;this.serverResponse.replyErrorResponse({ok:false,errorCode:"body_required",errorMessage:"Request body is required."});return}try{this.sharedMeta.body=JSON.parse(bodyBuffer.toString())}catch(error){this.logger_.error("parseBodyAsJson","invalid_body_json",error);this.serverResponse.statusCode=import_nanotron_api_server.HttpStatusCodes.Error_Client_422_Unprocessable_Entity;this.serverResponse.replyErrorResponse({ok:false,errorCode:"invalid_body_json",errorMessage:"Invalid JSON in request body."})}this.logger_.logProperty?.("body",this.sharedMeta.body)}var import_nanotron_api_server2=require("@alwatr/nanotron-api-server");var requireAccessToken=accessToken=>async function requireAccessToken_(){const userToken=getAuthBearer(this.headers.authorization);this.logger_.logMethodArgs?.("requireAccessToken",{userToken});if(userToken===null){this.serverResponse.statusCode=import_nanotron_api_server2.HttpStatusCodes.Error_Client_401_Unauthorized;this.serverResponse.replyErrorResponse({ok:false,errorCode:"authorization_required",errorMessage:"Authorization token required"});return}if(userToken!==accessToken){this.serverResponse.statusCode=import_nanotron_api_server2.HttpStatusCodes.Error_Client_403_Forbidden;this.serverResponse.replyErrorResponse({ok:false,errorCode:"access_denied",errorMessage:"Access denied, token is invalid!"})}};0&&(module.exports={getAuthBearer,parseBodyAsJson,requireAccessToken});
|
|
4
4
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** ๐ฆ @alwatr/pre-handlers v4.10.
|
|
2
|
-
__dev_mode__: console.debug("๐ฆ @alwatr/pre-handlers v4.10.
|
|
1
|
+
/** ๐ฆ @alwatr/pre-handlers v4.10.1 */
|
|
2
|
+
__dev_mode__: console.debug("๐ฆ @alwatr/pre-handlers v4.10.1");
|
|
3
3
|
function getAuthBearer(authorizationHeader){const auth=authorizationHeader?.split(" ");if(!auth||auth[0].toLowerCase()!=="bearer"||!auth[1]){return null}return auth[1]}import{HttpStatusCodes}from"@alwatr/nanotron-api-server";async function parseBodyAsJson(){this.logger_.logMethod?.("parseBodyAsJson");const bodyBuffer=await this.getBodyRaw();if(bodyBuffer.length===0){this.logger_.error("parseBodyAsJson","body_required");this.serverResponse.statusCode=HttpStatusCodes.Error_Client_422_Unprocessable_Entity;this.serverResponse.replyErrorResponse({ok:false,errorCode:"body_required",errorMessage:"Request body is required."});return}try{this.sharedMeta.body=JSON.parse(bodyBuffer.toString())}catch(error){this.logger_.error("parseBodyAsJson","invalid_body_json",error);this.serverResponse.statusCode=HttpStatusCodes.Error_Client_422_Unprocessable_Entity;this.serverResponse.replyErrorResponse({ok:false,errorCode:"invalid_body_json",errorMessage:"Invalid JSON in request body."})}this.logger_.logProperty?.("body",this.sharedMeta.body)}import{HttpStatusCodes as HttpStatusCodes2}from"@alwatr/nanotron-api-server";var requireAccessToken=accessToken=>async function requireAccessToken_(){const userToken=getAuthBearer(this.headers.authorization);this.logger_.logMethodArgs?.("requireAccessToken",{userToken});if(userToken===null){this.serverResponse.statusCode=HttpStatusCodes2.Error_Client_401_Unauthorized;this.serverResponse.replyErrorResponse({ok:false,errorCode:"authorization_required",errorMessage:"Authorization token required"});return}if(userToken!==accessToken){this.serverResponse.statusCode=HttpStatusCodes2.Error_Client_403_Forbidden;this.serverResponse.replyErrorResponse({ok:false,errorCode:"access_denied",errorMessage:"Access denied, token is invalid!"})}};export{getAuthBearer,parseBodyAsJson,requireAccessToken};
|
|
4
4
|
//# sourceMappingURL=main.mjs.map
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/pre-handlers",
|
|
3
3
|
"description": "Functions that will run before processing every defined route.",
|
|
4
|
-
"version": "4.10.
|
|
4
|
+
"version": "4.10.1",
|
|
5
5
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Alwatr/pre-handlers/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@alwatr/nanotron-api-server": "4.10.
|
|
8
|
+
"@alwatr/nanotron-api-server": "4.10.1"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@alwatr/nano-build": "^6.3.1",
|
|
@@ -67,7 +67,8 @@
|
|
|
67
67
|
"watch:es": "yarn run build:es --watch",
|
|
68
68
|
"watch:ts": "yarn run build:ts --watch --preserveWatchOutput"
|
|
69
69
|
},
|
|
70
|
+
"sideEffects": false,
|
|
70
71
|
"type": "module",
|
|
71
72
|
"types": "./dist/main.d.ts",
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "e077211736b90023d4842a23b252dc5284d0445a"
|
|
73
74
|
}
|