yedra 0.10.1 → 0.10.3
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/lib.d.ts +1 -0
- package/dist/lib.js +1 -0
- package/dist/routing/app.js +9 -1
- package/dist/validation/uuid.d.ts +11 -0
- package/dist/validation/uuid.js +23 -0
- package/package.json +4 -2
package/dist/lib.d.ts
CHANGED
|
@@ -23,3 +23,4 @@ export { string } from './validation/string.js';
|
|
|
23
23
|
export { _undefined as undefined } from './validation/undefined.js';
|
|
24
24
|
export { union } from './validation/union.js';
|
|
25
25
|
export { unknown } from './validation/unknown.js';
|
|
26
|
+
export { uuid } from './validation/uuid.js';
|
package/dist/lib.js
CHANGED
|
@@ -28,3 +28,4 @@ export { string } from './validation/string.js';
|
|
|
28
28
|
export { _undefined as undefined } from './validation/undefined.js';
|
|
29
29
|
export { union } from './validation/union.js';
|
|
30
30
|
export { unknown } from './validation/unknown.js';
|
|
31
|
+
export { uuid } from './validation/uuid.js';
|
package/dist/routing/app.js
CHANGED
|
@@ -57,7 +57,14 @@ export class App {
|
|
|
57
57
|
Bun.serve({
|
|
58
58
|
port: port,
|
|
59
59
|
fetch: async (req, server) => {
|
|
60
|
-
|
|
60
|
+
const url = new URL(req.url).pathname;
|
|
61
|
+
const begin = Date.now();
|
|
62
|
+
const response = await this.handle(req, server);
|
|
63
|
+
const duration = Date.now() - begin;
|
|
64
|
+
if (response !== undefined) {
|
|
65
|
+
console.log(`[${new Date().toISOString()}] ${req.method} ${url} -> ${response.status} (${duration}ms)`);
|
|
66
|
+
}
|
|
67
|
+
return response;
|
|
61
68
|
},
|
|
62
69
|
websocket: {
|
|
63
70
|
async open(ws) {
|
|
@@ -71,6 +78,7 @@ export class App {
|
|
|
71
78
|
},
|
|
72
79
|
},
|
|
73
80
|
});
|
|
81
|
+
console.log(`yedra listening on http://localhost:${port}...`);
|
|
74
82
|
}
|
|
75
83
|
static errorResponse(status, errorMessage) {
|
|
76
84
|
return Response.json({
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModifiableSchema } from './modifiable.js';
|
|
2
|
+
declare class UuidSchema extends ModifiableSchema<string> {
|
|
3
|
+
parse(obj: unknown): string;
|
|
4
|
+
documentation(): object;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A schema matching a universally unique identifier UUID
|
|
8
|
+
* of version 4.
|
|
9
|
+
*/
|
|
10
|
+
export declare const uuid: () => UuidSchema;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { validate, version } from 'uuid';
|
|
2
|
+
import { Issue, ValidationError } from './error.js';
|
|
3
|
+
import { ModifiableSchema } from './modifiable.js';
|
|
4
|
+
class UuidSchema extends ModifiableSchema {
|
|
5
|
+
parse(obj) {
|
|
6
|
+
if (typeof obj !== 'string' || !validate(obj) || version(obj) !== 4) {
|
|
7
|
+
throw new ValidationError([
|
|
8
|
+
new Issue('invalidType', [], 'uuid', typeof obj),
|
|
9
|
+
]);
|
|
10
|
+
}
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
documentation() {
|
|
14
|
+
return {
|
|
15
|
+
type: 'string',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A schema matching a universally unique identifier UUID
|
|
21
|
+
* of version 4.
|
|
22
|
+
*/
|
|
23
|
+
export const uuid = () => new UuidSchema();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yedra",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"repository": "github:0codekit/yedra",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"devDependencies": {
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
22
|
"type": "module",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"
|
|
24
|
+
"@types/uuid": "^10.0.0",
|
|
25
|
+
"glob": "^11.0.0",
|
|
26
|
+
"uuid": "^10.0.0"
|
|
25
27
|
}
|
|
26
28
|
}
|