@aeriajs/server 0.0.164 → 0.0.165
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/dist/appendPagination.d.ts +1 -1
- package/dist/appendPagination.js +4 -3
- package/dist/appendPagination.mjs +4 -3
- package/dist/constants.d.ts +4 -2
- package/dist/constants.js +4 -2
- package/dist/constants.mjs +4 -2
- package/dist/handler.d.ts +3 -3
- package/dist/handler.js +3 -5
- package/dist/handler.mjs +3 -5
- package/dist/init.d.ts +2 -2
- package/dist/routes.js +3 -2
- package/dist/routes.mjs +3 -2
- package/package.json +9 -9
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Context } from '@aeriajs/types';
|
|
2
|
-
export declare const appendPagination: (value:
|
|
2
|
+
export declare const appendPagination: (value: unknown, context: Context) => Promise<unknown>;
|
package/dist/appendPagination.js
CHANGED
|
@@ -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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
7
|
-
|
|
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,
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
package/dist/constants.mjs
CHANGED
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<
|
|
4
|
-
export declare const customVerbs: () => (parentContext: RouteContext) => Promise<
|
|
5
|
-
export declare const regularVerb: (functionName: keyof typeof functions) => (parentContext: RouteContext) => Promise<
|
|
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:
|
|
35
|
-
message: error.message,
|
|
34
|
+
code: types_1.ACError.UnknownError,
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
|
-
return context.error(
|
|
39
|
-
code:
|
|
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:
|
|
37
|
-
message: error.message
|
|
36
|
+
code: ACError.UnknownError
|
|
38
37
|
});
|
|
39
38
|
}
|
|
40
|
-
return context.error(
|
|
41
|
-
code:
|
|
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) =>
|
|
10
|
-
callback?: (context: Context) =>
|
|
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,
|
|
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
|
|
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,
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.0.165",
|
|
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.
|
|
37
|
-
"@aeriajs/builtins": "^0.0.
|
|
38
|
-
"@aeriajs/common": "^0.0.
|
|
39
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
40
|
-
"@aeriajs/http": "^0.0.
|
|
41
|
-
"@aeriajs/node-http": "^0.0.
|
|
42
|
-
"@aeriajs/server": "^0.0.
|
|
43
|
-
"@aeriajs/types": "^0.0.
|
|
36
|
+
"@aeriajs/core": "^0.0.163",
|
|
37
|
+
"@aeriajs/builtins": "^0.0.163",
|
|
38
|
+
"@aeriajs/common": "^0.0.99",
|
|
39
|
+
"@aeriajs/entrypoint": "^0.0.101",
|
|
40
|
+
"@aeriajs/http": "^0.0.112",
|
|
41
|
+
"@aeriajs/node-http": "^0.0.112",
|
|
42
|
+
"@aeriajs/server": "^0.0.165",
|
|
43
|
+
"@aeriajs/types": "^0.0.85",
|
|
44
44
|
"mongodb": "^6.5.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|