arcway 0.1.6 → 0.1.7
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/package.json +1 -1
- package/server/index.js +0 -2
- package/server/validation.js +7 -2
- package/server/route.js +0 -4
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type } from 'arktype';
|
|
2
2
|
import { buildContext } from './context.js';
|
|
3
3
|
import * as vault from './lib/vault/index.js';
|
|
4
|
-
import { defineRoute } from './route.js';
|
|
5
4
|
import boot from './boot.js';
|
|
6
5
|
import {
|
|
7
6
|
Arcway,
|
|
@@ -44,7 +43,6 @@ export {
|
|
|
44
43
|
createQueueStub,
|
|
45
44
|
createRateLimitMiddleware,
|
|
46
45
|
createTestContext,
|
|
47
|
-
defineRoute,
|
|
48
46
|
getApplicableSystemJobs,
|
|
49
47
|
registerSystemJobs,
|
|
50
48
|
type,
|
package/server/validation.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { ArkErrors } from 'arktype';
|
|
1
|
+
import { type, ArkErrors } from 'arktype';
|
|
2
2
|
function isArkErrors(value) {
|
|
3
3
|
return (
|
|
4
4
|
Array.isArray(value) && typeof value.summary === 'string' && typeof value.throw === 'function'
|
|
5
5
|
);
|
|
6
6
|
}
|
|
7
|
+
function ensureType(schema) {
|
|
8
|
+
if (typeof schema === 'function') return schema;
|
|
9
|
+
return type(schema);
|
|
10
|
+
}
|
|
7
11
|
function validate(schema, data) {
|
|
8
|
-
const
|
|
12
|
+
const compiled = ensureType(schema);
|
|
13
|
+
const result = compiled(data);
|
|
9
14
|
if (isArkErrors(result)) {
|
|
10
15
|
const fieldErrors = {};
|
|
11
16
|
for (const err of result) {
|
package/server/route.js
DELETED