@aeriajs/core 0.0.83 → 0.0.85
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/context.js
CHANGED
|
@@ -76,6 +76,9 @@ const createContext = async (options = {}) => {
|
|
|
76
76
|
created_at: new Date(),
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
|
+
context.error = (endpointError) => {
|
|
80
|
+
return (0, common_1.error)(endpointError, context);
|
|
81
|
+
};
|
|
79
82
|
context.limitRate = (params) => {
|
|
80
83
|
return (0, security_1.limitRate)(params, context);
|
|
81
84
|
};
|
package/dist/context.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import { unsafe } from "@aeriajs/common";
|
|
2
|
+
import { unsafe, error } from "@aeriajs/common";
|
|
3
3
|
import { getCollections } from "@aeriajs/entrypoint";
|
|
4
4
|
import { limitRate } from "@aeriajs/security";
|
|
5
5
|
import { getDatabaseCollection } from "./database.mjs";
|
|
@@ -51,6 +51,9 @@ export const createContext = async (options = {}) => {
|
|
|
51
51
|
created_at: /* @__PURE__ */ new Date()
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
|
+
context.error = (endpointError) => {
|
|
55
|
+
return error(endpointError, context);
|
|
56
|
+
};
|
|
54
57
|
context.limitRate = (params) => {
|
|
55
58
|
return limitRate(params, context);
|
|
56
59
|
};
|
|
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.upload = void 0;
|
|
27
27
|
const common_1 = require("@aeriajs/common");
|
|
28
|
+
const entrypoint_1 = require("@aeriajs/entrypoint");
|
|
28
29
|
const validation_1 = require("@aeriajs/validation");
|
|
29
30
|
const path = __importStar(require("path"));
|
|
30
31
|
const fs_1 = require("fs");
|
|
@@ -59,6 +60,10 @@ const streamToFs = (metadata, context) => {
|
|
|
59
60
|
});
|
|
60
61
|
};
|
|
61
62
|
const upload = async (_props, context) => {
|
|
63
|
+
const tempFileCollection = await (0, entrypoint_1.getCollection)('tempFile');
|
|
64
|
+
if (!tempFileCollection) {
|
|
65
|
+
throw new Error('The "tempFile" collection is absent, yet it is required to upload files.');
|
|
66
|
+
}
|
|
62
67
|
const headersEither = (0, validation_1.validate)(context.request.headers, {
|
|
63
68
|
type: 'object',
|
|
64
69
|
properties: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { isLeft, unwrapEither, left } from "@aeriajs/common";
|
|
3
|
+
import { getCollection } from "@aeriajs/entrypoint";
|
|
3
4
|
import { validate, validator } from "@aeriajs/validation";
|
|
4
5
|
import * as path from "path";
|
|
5
6
|
import { createWriteStream } from "fs";
|
|
@@ -28,6 +29,10 @@ const streamToFs = (metadata, context) => {
|
|
|
28
29
|
});
|
|
29
30
|
};
|
|
30
31
|
export const upload = async (_props, context) => {
|
|
32
|
+
const tempFileCollection = await getCollection("tempFile");
|
|
33
|
+
if (!tempFileCollection) {
|
|
34
|
+
throw new Error('The "tempFile" collection is absent, yet it is required to upload files.');
|
|
35
|
+
}
|
|
31
36
|
const headersEither = validate(context.request.headers, {
|
|
32
37
|
type: "object",
|
|
33
38
|
properties: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.85",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"mongodb-memory-server": "^9.2.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@aeriajs/builtins": "^0.0.
|
|
45
|
-
"@aeriajs/common": "^0.0.
|
|
46
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
47
|
-
"@aeriajs/http": "^0.0.
|
|
48
|
-
"@aeriajs/security": "^0.0.
|
|
49
|
-
"@aeriajs/types": "^0.0.
|
|
50
|
-
"@aeriajs/validation": "^0.0.
|
|
44
|
+
"@aeriajs/builtins": "^0.0.85",
|
|
45
|
+
"@aeriajs/common": "^0.0.51",
|
|
46
|
+
"@aeriajs/entrypoint": "^0.0.51",
|
|
47
|
+
"@aeriajs/http": "^0.0.59",
|
|
48
|
+
"@aeriajs/security": "^0.0.85",
|
|
49
|
+
"@aeriajs/types": "^0.0.48",
|
|
50
|
+
"@aeriajs/validation": "^0.0.54"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"mongodb": "^6.5.0",
|