my-q-format-response-aws-lambda 1.0.26 → 1.0.28

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.
Files changed (3) hide show
  1. package/index.js +21 -3
  2. package/index.ts +28 -3
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -7,6 +7,7 @@ exports.StatusResult = StatusResult;
7
7
  StatusResult.ok = 'Ok';
8
8
  StatusResult.error = 'Error';
9
9
  StatusResult.notFound = 'NotFound';
10
+ StatusResult.unauthorized = 'Unauthorized';
10
11
  class StatusCode {
11
12
  }
12
13
  exports.StatusCode = StatusCode;
@@ -189,6 +190,23 @@ class CreateResponse {
189
190
  });
190
191
  return result.bodyToString();
191
192
  }
193
+ /**
194
+ * Unauthorized
195
+ * @param error
196
+ * @param statusCode
197
+ * @param message
198
+ * @param bodyWrap
199
+ */
200
+ static unauthorized({ error = null, statusCode = StatusCode.Unauthorized, message = 'Unauthorized', bodyWrap = true, }) {
201
+ const result = new Result({
202
+ statusCode,
203
+ statusResult: StatusResult.unauthorized,
204
+ error,
205
+ message,
206
+ bodyWrap,
207
+ });
208
+ return result.bodyToString();
209
+ }
192
210
  /**
193
211
  * Custom
194
212
  * @param statusCode
@@ -277,9 +295,9 @@ const messagesREST = (prefix, suffix = '') => {
277
295
  USER_LOGOUT: `${prefix}_USER_LOGOUT${suffix}`,
278
296
  NOT_USER_LOGOUT: `${prefix}_NOT_USER_LOGOUT${suffix}`,
279
297
  ERROR_USER_LOGOUT: `${prefix}_ERROR_USER_LOGOUT${suffix}`,
280
- USER_REGISTRATION_REFRESH: `${prefix}_USER_REGISTRATION_REFRESH${suffix}`,
281
- NOT_USER_REGISTRATION_REFRESH: `${prefix}_NOT_USER_REGISTRATION_REFRESH${suffix}`,
282
- ERROR_USER_REGISTRATION_REFRESH: `${prefix}_ERROR_USER_REGISTRATION_REFRESH${suffix}`,
298
+ USER_AUTHENTICATION_REFRESH: `${prefix}_USER_AUTHENTICATION_REFRESH${suffix}`,
299
+ NOT_USER_AUTHENTICATION_REFRESH: `${prefix}_NOT_USER_AUTHENTICATION_REFRESH${suffix}`,
300
+ ERROR_USER_AUTHENTICATION_REFRESH: `${prefix}_ERROR_USER_AUTHENTICATION_REFRESH${suffix}`,
283
301
  };
284
302
  };
285
303
  exports.messagesREST = messagesREST;
package/index.ts CHANGED
@@ -2,6 +2,7 @@ export class StatusResult {
2
2
  static ok = 'Ok';
3
3
  static error = 'Error';
4
4
  static notFound = 'NotFound';
5
+ static unauthorized = 'Unauthorized';
5
6
  }
6
7
 
7
8
  export class StatusCode {
@@ -271,6 +272,30 @@ export class CreateResponse {
271
272
  return result.bodyToString();
272
273
  }
273
274
 
275
+
276
+ /**
277
+ * Unauthorized
278
+ * @param error
279
+ * @param statusCode
280
+ * @param message
281
+ * @param bodyWrap
282
+ */
283
+ static unauthorized({
284
+ error = null,
285
+ statusCode = StatusCode.Unauthorized,
286
+ message = 'Unauthorized',
287
+ bodyWrap = true,
288
+ }: TFuncParams): ResponseVoAWS {
289
+ const result = new Result({
290
+ statusCode,
291
+ statusResult: StatusResult.unauthorized,
292
+ error,
293
+ message,
294
+ bodyWrap,
295
+ });
296
+ return result.bodyToString();
297
+ }
298
+
274
299
  /**
275
300
  * Custom
276
301
  * @param statusCode
@@ -389,9 +414,9 @@ export const messagesREST = (prefix: string, suffix: string = '') => {
389
414
  NOT_USER_LOGOUT: `${prefix}_NOT_USER_LOGOUT${suffix}`,
390
415
  ERROR_USER_LOGOUT: `${prefix}_ERROR_USER_LOGOUT${suffix}`,
391
416
 
392
- USER_REGISTRATION_REFRESH: `${prefix}_USER_REGISTRATION_REFRESH${suffix}`,
393
- NOT_USER_REGISTRATION_REFRESH: `${prefix}_NOT_USER_REGISTRATION_REFRESH${suffix}`,
394
- ERROR_USER_REGISTRATION_REFRESH: `${prefix}_ERROR_USER_REGISTRATION_REFRESH${suffix}`,
417
+ USER_AUTHENTICATION_REFRESH: `${prefix}_USER_AUTHENTICATION_REFRESH${suffix}`,
418
+ NOT_USER_AUTHENTICATION_REFRESH: `${prefix}_NOT_USER_AUTHENTICATION_REFRESH${suffix}`,
419
+ ERROR_USER_AUTHENTICATION_REFRESH: `${prefix}_ERROR_USER_AUTHENTICATION_REFRESH${suffix}`,
395
420
  };
396
421
  };
397
422
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-q-format-response-aws-lambda",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "homepage": "https://github.com/zhukyuri/my-q-format-response-aws-lambda",
5
5
  "description": "my-q-format-response-aws-lambda",
6
6
  "main": "index.js",