@miso.ai/doggoganger 0.9.0-beta.9 → 0.9.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.
@@ -0,0 +1,6 @@
1
+ export function parseBodyIfNecessary(body) {
2
+ if (typeof body === 'string') {
3
+ return JSON.parse(body);
4
+ }
5
+ return body;
6
+ }
package/src/utils.js CHANGED
@@ -24,3 +24,20 @@ export async function exclusion(ctx, next) {
24
24
  ctx.status = 404;
25
25
  }
26
26
  }
27
+
28
+ export async function delay(time) {
29
+ return new Promise(resolve => setTimeout(resolve, time));
30
+ }
31
+
32
+ export function trimObj(obj) {
33
+ if (typeof obj !== 'object') {
34
+ return obj;
35
+ }
36
+ const trimmed = {};
37
+ for (const k in obj) {
38
+ if (Object.prototype.hasOwnProperty.call(obj, k) && obj[k] !== undefined) {
39
+ trimmed[k] = obj[k];
40
+ }
41
+ }
42
+ return trimmed;
43
+ }
@@ -1,10 +0,0 @@
1
- import { products as _products } from '../data/index.js';
2
-
3
- export function products(ctx) {
4
- const { rows = 5 } = JSON.parse(ctx.request.body);
5
- ctx.body = {
6
- data: {
7
- products: [..._products({ rows })],
8
- },
9
- };
10
- }
File without changes