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

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 +18 -0
  2. package/index.ts +25 -0
  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
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
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.27",
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",