@rabstack/rab-api 1.3.0 → 1.4.0

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/README.md CHANGED
@@ -389,5 +389,4 @@ app.listen(3000);
389
389
  MIT © Softin Hub
390
390
 
391
391
  ## Support
392
-
393
392
  Email: softin.developer@gmail.com
package/index.cjs.js CHANGED
@@ -577,7 +577,7 @@ const authHandler = (isProtected, config)=>(req, res, next)=>{
577
577
  const token = extractTokenFromHeader(req);
578
578
  if (!token) {
579
579
  console.log('authHandler:UnauthorizedException:Token Not Found');
580
- throw new UnauthorizedException();
580
+ throw new UnauthorizedException('Unauthorized', config.errorCode);
581
581
  }
582
582
  try {
583
583
  const payload = jwt.verify(token, config.jwt.secret_key);
@@ -585,7 +585,7 @@ const authHandler = (isProtected, config)=>(req, res, next)=>{
585
585
  return next();
586
586
  } catch (err) {
587
587
  console.error('authHandler:JWT Error:', err.message);
588
- throw new UnauthorizedException();
588
+ throw new UnauthorizedException('Unauthorized', config.errorCode);
589
589
  }
590
590
  };
591
591
 
package/index.esm.d.ts CHANGED
@@ -121,6 +121,7 @@ export declare function AtomRoute(method: HttpMethod, path: string, options?: Co
121
121
  export declare const authHandler: (isProtected: boolean, config: AuthHandlerOptions) => (req: any, res: Response_2, next: NextFunction) => void;
122
122
 
123
123
  export declare type AuthHandlerOptions = {
124
+ errorCode?: string;
124
125
  jwt: {
125
126
  secret_key: string;
126
127
  algorithms: any;
package/index.esm.js CHANGED
@@ -575,7 +575,7 @@ const authHandler = (isProtected, config)=>(req, res, next)=>{
575
575
  const token = extractTokenFromHeader(req);
576
576
  if (!token) {
577
577
  console.log('authHandler:UnauthorizedException:Token Not Found');
578
- throw new UnauthorizedException();
578
+ throw new UnauthorizedException('Unauthorized', config.errorCode);
579
579
  }
580
580
  try {
581
581
  const payload = jwt.verify(token, config.jwt.secret_key);
@@ -583,7 +583,7 @@ const authHandler = (isProtected, config)=>(req, res, next)=>{
583
583
  return next();
584
584
  } catch (err) {
585
585
  console.error('authHandler:JWT Error:', err.message);
586
- throw new UnauthorizedException();
586
+ throw new UnauthorizedException('Unauthorized', config.errorCode);
587
587
  }
588
588
  };
589
589
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabstack/rab-api",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "A TypeScript REST API framework built on Express.js with decorator-based routing, dependency injection, and built-in validation",
5
5
  "author": "Softin",
6
6
  "license": "MIT",