@glass-cannon/server 0.9.1 → 0.10.0

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.
@@ -0,0 +1,16 @@
1
+ import type { Response } from '../response.js';
2
+ export declare function json({ status, body, headers: customHeaders, }: {
3
+ status: number;
4
+ body?: unknown;
5
+ headers?: HeadersInit;
6
+ }): Response;
7
+ export declare function text({ status, body, headers: customHeaders, }: {
8
+ status: number;
9
+ body: string;
10
+ headers?: HeadersInit;
11
+ }): Response;
12
+ export declare function html({ status, body, headers: customHeaders, }: {
13
+ status: number;
14
+ body: string;
15
+ headers?: HeadersInit;
16
+ }): Response;
@@ -0,0 +1,23 @@
1
+ import { writeJson, writeText } from '../stream.js';
2
+ export function json({ status, body, headers: customHeaders, }) {
3
+ const headers = new Headers(customHeaders);
4
+ if (!headers.has('Content-Type') && body !== undefined) {
5
+ headers.set('Content-Type', 'application/json');
6
+ }
7
+ return { status, headers, body: writeJson(body) };
8
+ }
9
+ export function text({ status, body, headers: customHeaders, }) {
10
+ const headers = new Headers(customHeaders);
11
+ if (!headers.has('Content-Type')) {
12
+ headers.set('Content-Type', 'text/plain');
13
+ }
14
+ return { status, headers, body: writeText(body) };
15
+ }
16
+ export function html({ status, body, headers: customHeaders, }) {
17
+ const headers = new Headers(customHeaders);
18
+ if (!headers.has('Content-Type')) {
19
+ headers.set('Content-Type', 'text/html');
20
+ }
21
+ return { status, headers, body: writeText(body) };
22
+ }
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contentType/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,UAAU,IAAI,CAAC,EACnB,MAAM,EACN,IAAI,EACJ,OAAO,EAAE,aAAa,GAKvB;IACC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,EACnB,MAAM,EACN,IAAI,EACJ,OAAO,EAAE,aAAa,GAKvB;IACC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,EACnB,MAAM,EACN,IAAI,EACJ,OAAO,EAAE,aAAa,GAKvB;IACC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;AACpD,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@glass-cannon/server",
3
3
  "type": "module",
4
- "version": "0.9.1",
4
+ "version": "0.10.0",
5
5
  "exports": {
6
6
  ".": {
7
7
  "import": "./dist/index.js",