@aeriajs/server 0.0.164 → 0.0.166

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.
@@ -1,2 +1,2 @@
1
1
  import { type Context } from '@aeriajs/types';
2
- export declare const appendPagination: (value: any, context: Context) => Promise<any>;
2
+ export declare const appendPagination: (value: unknown, context: Context) => Promise<unknown>;
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.appendPagination = void 0;
4
4
  const types_1 = require("@aeriajs/types");
5
+ const common_1 = require("@aeriajs/common");
5
6
  const core_1 = require("@aeriajs/core");
6
7
  const appendPagination = async (value, context) => {
7
8
  if (context.calledFunction === 'getAll' && value) {
8
- const { error, result } = value;
9
- if (error) {
10
- return types_1.Result.error(error);
9
+ if (!(0, common_1.isResult)(value)) {
10
+ return value;
11
11
  }
12
+ const { result } = value;
12
13
  if (Array.isArray(result)) {
13
14
  return types_1.Result.result({
14
15
  data: result,
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  import { Result } from "@aeriajs/types";
3
+ import { isResult } from "@aeriajs/common";
3
4
  import { makePagination } from "@aeriajs/core";
4
5
  export const appendPagination = async (value, context) => {
5
6
  if (context.calledFunction === "getAll" && value) {
6
- const { error, result } = value;
7
- if (error) {
8
- return Result.error(error);
7
+ if (!isResult(value)) {
8
+ return value;
9
9
  }
10
+ const { result } = value;
10
11
  if (Array.isArray(result)) {
11
12
  return Result.result({
12
13
  data: result,
@@ -1,6 +1,8 @@
1
1
  export declare const DEFAULT_API_CONFIG: {
2
2
  baseUrl: "/";
3
3
  port: number;
4
- paginationLimit: number;
5
- security: {};
4
+ defaultPaginationLimit: number;
5
+ security: {
6
+ paginationLimit: number;
7
+ };
6
8
  };
package/dist/constants.js CHANGED
@@ -4,6 +4,8 @@ exports.DEFAULT_API_CONFIG = void 0;
4
4
  exports.DEFAULT_API_CONFIG = {
5
5
  baseUrl: '/',
6
6
  port: 3000,
7
- paginationLimit: 10,
8
- security: {},
7
+ defaultPaginationLimit: 10,
8
+ security: {
9
+ paginationLimit: 100,
10
+ },
9
11
  };
@@ -2,6 +2,8 @@
2
2
  export const DEFAULT_API_CONFIG = {
3
3
  baseUrl: "/",
4
4
  port: 3e3,
5
- paginationLimit: 10,
6
- security: {}
5
+ defaultPaginationLimit: 10,
6
+ security: {
7
+ paginationLimit: 100
8
+ }
7
9
  };
package/dist/handler.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { RouteContext } from '@aeriajs/types';
2
2
  import type { functions } from '@aeriajs/core';
3
- export declare const safeHandle: (fn: (context: RouteContext) => Promise<object>, context: RouteContext) => () => Promise<unknown>;
4
- export declare const customVerbs: () => (parentContext: RouteContext) => Promise<any>;
5
- export declare const regularVerb: (functionName: keyof typeof functions) => (parentContext: RouteContext) => Promise<any>;
3
+ export declare const safeHandle: (fn: (context: RouteContext) => Promise<unknown>, context: RouteContext) => () => Promise<unknown>;
4
+ export declare const customVerbs: () => (parentContext: RouteContext) => Promise<unknown>;
5
+ export declare const regularVerb: (functionName: keyof typeof functions) => (parentContext: RouteContext) => Promise<unknown>;
package/dist/handler.js CHANGED
@@ -31,13 +31,11 @@ const safeHandle = (fn, context) => async () => {
31
31
  }
32
32
  if (context.request.headers['sec-fetch-mode'] === 'cors') {
33
33
  return types_1.Result.error({
34
- code: error.code || error.name,
35
- message: error.message,
34
+ code: types_1.ACError.UnknownError,
36
35
  });
37
36
  }
38
- return context.error(error.httpStatus || types_1.HTTPStatus.InternalServerError, {
39
- code: error.code || error.name,
40
- message: error.message,
37
+ return context.error(types_1.HTTPStatus.InternalServerError, {
38
+ code: types_1.ACError.UnknownError,
41
39
  });
42
40
  }
43
41
  };
package/dist/handler.mjs CHANGED
@@ -33,13 +33,11 @@ export const safeHandle = (fn, context) => async () => {
33
33
  }
34
34
  if (context.request.headers["sec-fetch-mode"] === "cors") {
35
35
  return Result.error({
36
- code: error.code || error.name,
37
- message: error.message
36
+ code: ACError.UnknownError
38
37
  });
39
38
  }
40
- return context.error(error.httpStatus || HTTPStatus.InternalServerError, {
41
- code: error.code || error.name,
42
- message: error.message
39
+ return context.error(HTTPStatus.InternalServerError, {
40
+ code: ACError.UnknownError
43
41
  });
44
42
  }
45
43
  };
package/dist/init.d.ts CHANGED
@@ -6,8 +6,8 @@ export type InitApiConfig = Omit<ApiConfig, keyof typeof DEFAULT_API_CONFIG> & P
6
6
  export type InitOptions = {
7
7
  config?: InitApiConfig;
8
8
  router?: ReturnType<typeof createRouter>;
9
- setup?: (context: Context) => any;
10
- callback?: (context: Context) => any;
9
+ setup?: (context: Context) => unknown;
10
+ callback?: (context: Context) => unknown;
11
11
  collections?: Record<string, Collection & {
12
12
  description: NonCircularJsonSchema;
13
13
  }>;
package/dist/routes.js CHANGED
@@ -21,10 +21,11 @@ const registerRoutes = () => {
21
21
  collectionName: 'file',
22
22
  parentContext,
23
23
  });
24
- const [fileId, options] = context.request.fragments;
24
+ const [fileId, optionsString] = context.request.fragments;
25
+ const options = optionsString.split('/').filter((option) => option === 'picture' || option === 'download');
25
26
  return context.collections.file.functions.download({
26
27
  fileId,
27
- options: options.split('/'),
28
+ options,
28
29
  });
29
30
  }));
30
31
  router.GET('/(\\w+)/id/(\\w+)', defaultHandler((0, handler_js_1.regularVerb)('get')));
package/dist/routes.mjs CHANGED
@@ -23,10 +23,11 @@ export const registerRoutes = () => {
23
23
  collectionName: "file",
24
24
  parentContext
25
25
  });
26
- const [fileId, options] = context.request.fragments;
26
+ const [fileId, optionsString] = context.request.fragments;
27
+ const options = optionsString.split("/").filter((option) => option === "picture" || option === "download");
27
28
  return context.collections.file.functions.download({
28
29
  fileId,
29
- options: options.split("/")
30
+ options
30
31
  });
31
32
  }));
32
33
  router.GET("/(\\w+)/id/(\\w+)", defaultHandler(regularVerb("get")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/server",
3
- "version": "0.0.164",
3
+ "version": "0.0.166",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,14 +33,14 @@
33
33
  "mongodb": "^6.5.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@aeriajs/core": "^0.0.162",
37
- "@aeriajs/builtins": "^0.0.162",
38
- "@aeriajs/common": "^0.0.98",
39
- "@aeriajs/entrypoint": "^0.0.100",
40
- "@aeriajs/http": "^0.0.111",
41
- "@aeriajs/node-http": "^0.0.111",
42
- "@aeriajs/server": "^0.0.164",
43
- "@aeriajs/types": "^0.0.84",
36
+ "@aeriajs/core": "^0.0.164",
37
+ "@aeriajs/builtins": "^0.0.164",
38
+ "@aeriajs/common": "^0.0.100",
39
+ "@aeriajs/entrypoint": "^0.0.102",
40
+ "@aeriajs/http": "^0.0.113",
41
+ "@aeriajs/node-http": "^0.0.113",
42
+ "@aeriajs/server": "^0.0.166",
43
+ "@aeriajs/types": "^0.0.86",
44
44
  "mongodb": "^6.5.0"
45
45
  },
46
46
  "scripts": {