yedra 0.14.0 → 0.14.2

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.
@@ -177,17 +177,22 @@ export class Yedra {
177
177
  headers: req.headers,
178
178
  });
179
179
  const status = response.status ?? 200;
180
- res.writeHead(status, response.headers);
181
180
  if (response.body instanceof ReadableStream) {
181
+ res.writeHead(status, response.headers);
182
182
  for await (const chunk of response.body) {
183
183
  res.write(chunk);
184
184
  }
185
185
  }
186
+ else if (response.body instanceof Uint8Array) {
187
+ res.writeHead(status, response.headers);
188
+ res.write(response.body);
189
+ }
186
190
  else {
187
- const buffer = response.body instanceof Uint8Array
188
- ? response.body
189
- : JSON.stringify(response.body);
190
- res.write(buffer);
191
+ res.writeHead(status, {
192
+ 'content-type': 'application/json',
193
+ ...response.headers,
194
+ });
195
+ res.write(JSON.stringify(response.body));
191
196
  }
192
197
  res.end();
193
198
  const duration = Date.now() - begin;
@@ -1,3 +1,4 @@
1
1
  import type { Typeof } from '../validation/body.js';
2
+ import { type ObjectSchema } from '../validation/object.js';
2
3
  import type { Schema } from '../validation/schema.js';
3
- export declare const parseEnv: <T extends Schema<unknown>>(schema: T) => Typeof<T>;
4
+ export declare const parseEnv: <T extends Record<string, Schema<unknown>>>(shape: T) => Typeof<ObjectSchema<T>>;
@@ -1,7 +1,8 @@
1
1
  import { ValidationError } from '../validation/error.js';
2
- export const parseEnv = (schema) => {
2
+ import { laxObject } from '../validation/object.js';
3
+ export const parseEnv = (shape) => {
3
4
  try {
4
- return schema.parse(process.env);
5
+ return laxObject(shape).parse(process.env);
5
6
  }
6
7
  catch (error) {
7
8
  if (error instanceof ValidationError) {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "yedra",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "repository": "github:0codekit/yedra",
5
5
  "main": "dist/index.js",
6
6
  "devDependencies": {
7
7
  "@biomejs/biome": "^1.9.4",
8
- "@types/bun": "^1.2.10",
9
- "@types/node": "^22.14.1",
8
+ "@types/bun": "^1.2.12",
9
+ "@types/node": "^22.15.17",
10
10
  "@types/uuid": "^10.0.0",
11
11
  "@types/ws": "^8.18.1",
12
12
  "typescript": "^5.8.3"
@@ -25,6 +25,6 @@
25
25
  "dependencies": {
26
26
  "mime": "^4.0.7",
27
27
  "uuid": "^11.1.0",
28
- "ws": "^8.18.1"
28
+ "ws": "^8.18.2"
29
29
  }
30
30
  }