@lithia-js/core 1.0.0-canary.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.
Files changed (91) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/CHANGELOG.md +13 -0
  3. package/LICENSE +21 -0
  4. package/README.md +60 -0
  5. package/dist/config.d.ts +101 -0
  6. package/dist/config.js +113 -0
  7. package/dist/config.js.map +1 -0
  8. package/dist/context/event-context.d.ts +53 -0
  9. package/dist/context/event-context.js +42 -0
  10. package/dist/context/event-context.js.map +1 -0
  11. package/dist/context/index.d.ts +16 -0
  12. package/dist/context/index.js +29 -0
  13. package/dist/context/index.js.map +1 -0
  14. package/dist/context/lithia-context.d.ts +47 -0
  15. package/dist/context/lithia-context.js +43 -0
  16. package/dist/context/lithia-context.js.map +1 -0
  17. package/dist/context/route-context.d.ts +74 -0
  18. package/dist/context/route-context.js +42 -0
  19. package/dist/context/route-context.js.map +1 -0
  20. package/dist/env.d.ts +1 -0
  21. package/dist/env.js +32 -0
  22. package/dist/env.js.map +1 -0
  23. package/dist/errors.d.ts +51 -0
  24. package/dist/errors.js +80 -0
  25. package/dist/errors.js.map +1 -0
  26. package/dist/hooks/dependency-hooks.d.ts +105 -0
  27. package/dist/hooks/dependency-hooks.js +96 -0
  28. package/dist/hooks/dependency-hooks.js.map +1 -0
  29. package/dist/hooks/event-hooks.d.ts +61 -0
  30. package/dist/hooks/event-hooks.js +70 -0
  31. package/dist/hooks/event-hooks.js.map +1 -0
  32. package/dist/hooks/index.d.ts +41 -0
  33. package/dist/hooks/index.js +59 -0
  34. package/dist/hooks/index.js.map +1 -0
  35. package/dist/hooks/route-hooks.d.ts +154 -0
  36. package/dist/hooks/route-hooks.js +174 -0
  37. package/dist/hooks/route-hooks.js.map +1 -0
  38. package/dist/lib.d.ts +10 -0
  39. package/dist/lib.js +30 -0
  40. package/dist/lib.js.map +1 -0
  41. package/dist/lithia.d.ts +447 -0
  42. package/dist/lithia.js +649 -0
  43. package/dist/lithia.js.map +1 -0
  44. package/dist/logger.d.ts +11 -0
  45. package/dist/logger.js +55 -0
  46. package/dist/logger.js.map +1 -0
  47. package/dist/module-loader.d.ts +12 -0
  48. package/dist/module-loader.js +78 -0
  49. package/dist/module-loader.js.map +1 -0
  50. package/dist/server/event-processor.d.ts +195 -0
  51. package/dist/server/event-processor.js +253 -0
  52. package/dist/server/event-processor.js.map +1 -0
  53. package/dist/server/http-server.d.ts +196 -0
  54. package/dist/server/http-server.js +295 -0
  55. package/dist/server/http-server.js.map +1 -0
  56. package/dist/server/middlewares/validation.d.ts +12 -0
  57. package/dist/server/middlewares/validation.js +34 -0
  58. package/dist/server/middlewares/validation.js.map +1 -0
  59. package/dist/server/request-processor.d.ts +400 -0
  60. package/dist/server/request-processor.js +652 -0
  61. package/dist/server/request-processor.js.map +1 -0
  62. package/dist/server/request.d.ts +73 -0
  63. package/dist/server/request.js +207 -0
  64. package/dist/server/request.js.map +1 -0
  65. package/dist/server/response.d.ts +69 -0
  66. package/dist/server/response.js +173 -0
  67. package/dist/server/response.js.map +1 -0
  68. package/package.json +46 -0
  69. package/src/config.ts +212 -0
  70. package/src/context/event-context.ts +66 -0
  71. package/src/context/index.ts +32 -0
  72. package/src/context/lithia-context.ts +59 -0
  73. package/src/context/route-context.ts +89 -0
  74. package/src/env.ts +31 -0
  75. package/src/errors.ts +96 -0
  76. package/src/hooks/dependency-hooks.ts +122 -0
  77. package/src/hooks/event-hooks.ts +69 -0
  78. package/src/hooks/index.ts +58 -0
  79. package/src/hooks/route-hooks.ts +177 -0
  80. package/src/lib.ts +27 -0
  81. package/src/lithia.ts +777 -0
  82. package/src/logger.ts +66 -0
  83. package/src/module-loader.ts +45 -0
  84. package/src/server/event-processor.ts +344 -0
  85. package/src/server/http-server.ts +371 -0
  86. package/src/server/middlewares/validation.ts +46 -0
  87. package/src/server/request-processor.ts +860 -0
  88. package/src/server/request.ts +247 -0
  89. package/src/server/response.ts +204 -0
  90. package/tsconfig.build.tsbuildinfo +1 -0
  91. package/tsconfig.json +8 -0
@@ -0,0 +1,73 @@
1
+ import type { IncomingHttpHeaders, IncomingMessage } from "node:http";
2
+ import { type FileInfo } from "busboy";
3
+ import { type Cookies } from "cookie";
4
+ import type { Lithia } from "../lithia";
5
+ /** Route parameters extracted from the route matcher. */
6
+ export type Params = Record<string, any>;
7
+ /** Parsed query parameters. Values may be a string or an array for repeated keys. */
8
+ export type Query = Record<string, any>;
9
+ /** Represents an uploaded file. */
10
+ export interface UploadedFile extends FileInfo {
11
+ /** Field name in the form. */
12
+ fieldname: string;
13
+ /** File buffer. */
14
+ buffer: Buffer;
15
+ }
16
+ /** Request wrapper passed to route handlers.
17
+ *
18
+ * Provides convenient accessors for headers, params, query, body and helpers
19
+ * such as `ip()` and `isSecure()`. The wrapper also exposes a simple
20
+ * per-request storage via `get()`/`set()` and cookie parsing helpers.
21
+ */
22
+ export declare class LithiaRequest {
23
+ private readonly req;
24
+ private readonly lithia;
25
+ headers: Readonly<IncomingHttpHeaders>;
26
+ method: Readonly<string>;
27
+ params: Params;
28
+ pathname: Readonly<string>;
29
+ query: Query;
30
+ private storage;
31
+ private _bodyCache;
32
+ private _filesCache;
33
+ private _cookies;
34
+ /**
35
+ * Wrap a Node `IncomingMessage` into a `LithiaRequest`.
36
+ *
37
+ * `lithia` is the runtime instance and is stored in request-local
38
+ * storage under the `lithia` key for handlers that need access.
39
+ */
40
+ constructor(req: IncomingMessage, lithia: Lithia);
41
+ /**
42
+ * Read and parse the request body. For JSON content-type this returns the
43
+ * parsed object; for other content types it returns the raw string. The
44
+ * result is cached and subsequent calls return the cached value.
45
+ */
46
+ body<T>(): Promise<T>;
47
+ /**
48
+ * Get uploaded files from a multipart/form-data request.
49
+ */
50
+ files(): Promise<UploadedFile[]>;
51
+ /** Set the request body manually (e.g. after validation/sanitization). */
52
+ setBody(value: unknown): void;
53
+ private parseMultipart;
54
+ /** Retrieve a value from per-request storage. */
55
+ get<T>(key: string): T | undefined;
56
+ /** Store a value in per-request storage. */
57
+ set(key: string, value: unknown): void;
58
+ /** Parse cookies from the `Cookie` header. */
59
+ cookies(): Cookies;
60
+ /** Return a single cookie value by name. */
61
+ cookie(name: string): string | undefined;
62
+ /** Client IP address (considers `X-Forwarded-For` and `X-Real-IP`). */
63
+ ip(): string;
64
+ /** `User-Agent` header value or empty string. */
65
+ userAgent(): string;
66
+ /** Return true when the request was made over TLS. */
67
+ isSecure(): boolean;
68
+ /** Host header or `unknown` when missing. */
69
+ host(): string;
70
+ /** Full URL constructed from host and pathname. */
71
+ url(): string;
72
+ }
73
+ export declare function parseQueryToObject(raw: URLSearchParams): Query;
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LithiaRequest = void 0;
7
+ exports.parseQueryToObject = parseQueryToObject;
8
+ const busboy_1 = __importDefault(require("busboy"));
9
+ const cookie_1 = require("cookie");
10
+ /** Request wrapper passed to route handlers.
11
+ *
12
+ * Provides convenient accessors for headers, params, query, body and helpers
13
+ * such as `ip()` and `isSecure()`. The wrapper also exposes a simple
14
+ * per-request storage via `get()`/`set()` and cookie parsing helpers.
15
+ */
16
+ class LithiaRequest {
17
+ req;
18
+ lithia;
19
+ headers;
20
+ method;
21
+ params;
22
+ pathname;
23
+ query;
24
+ storage = new Map();
25
+ _bodyCache = null;
26
+ _filesCache = null;
27
+ _cookies = null;
28
+ /**
29
+ * Wrap a Node `IncomingMessage` into a `LithiaRequest`.
30
+ *
31
+ * `lithia` is the runtime instance and is stored in request-local
32
+ * storage under the `lithia` key for handlers that need access.
33
+ */
34
+ constructor(req, lithia) {
35
+ this.req = req;
36
+ this.lithia = lithia;
37
+ const protocol = req.headers["x-forwarded-proto"] === "https" ||
38
+ req.socket?.encrypted === true
39
+ ? "https"
40
+ : "http";
41
+ const host = req.headers.host || "unknown";
42
+ const fullUrl = `${protocol}://${host}${req.url || "/"}`;
43
+ const url = new URL(fullUrl);
44
+ this.pathname = url.pathname;
45
+ this.method = (req.method || "GET").toUpperCase();
46
+ this.headers = req.headers;
47
+ this.query = parseQueryToObject(url.searchParams);
48
+ this.params = {};
49
+ this.storage.set("lithia", this.lithia);
50
+ }
51
+ /**
52
+ * Read and parse the request body. For JSON content-type this returns the
53
+ * parsed object; for other content types it returns the raw string. The
54
+ * result is cached and subsequent calls return the cached value.
55
+ */
56
+ async body() {
57
+ if (!["POST", "PUT", "PATCH", "DELETE"].includes(this.method)) {
58
+ return {};
59
+ }
60
+ if (this._bodyCache !== null)
61
+ return this._bodyCache;
62
+ const contentType = (this.headers["content-type"] || "");
63
+ if (contentType.includes("multipart/form-data")) {
64
+ await this.parseMultipart();
65
+ return this._bodyCache;
66
+ }
67
+ const contentLength = parseInt(this.headers["content-length"] || "0", 10);
68
+ const maxBodySize = this.lithia.options.http.maxBodySize || 1024 * 1024;
69
+ if (contentLength > maxBodySize) {
70
+ throw new Error("Request body too large");
71
+ }
72
+ const body = await new Promise((resolve, reject) => {
73
+ let bodyData = "";
74
+ this.req.on("data", (chunk) => {
75
+ bodyData += chunk;
76
+ if (bodyData.length > maxBodySize) {
77
+ reject(new Error("Request body too large"));
78
+ }
79
+ });
80
+ this.req.on("end", () => {
81
+ if (!bodyData)
82
+ return resolve({});
83
+ try {
84
+ if (contentType.includes("application/json")) {
85
+ resolve(JSON.parse(bodyData));
86
+ }
87
+ else {
88
+ resolve(bodyData);
89
+ }
90
+ }
91
+ catch (err) {
92
+ reject(err);
93
+ }
94
+ });
95
+ this.req.on("error", (err) => reject(err));
96
+ });
97
+ this._bodyCache = body;
98
+ this.storage.set("body", body);
99
+ return body;
100
+ }
101
+ /**
102
+ * Get uploaded files from a multipart/form-data request.
103
+ */
104
+ async files() {
105
+ const contentType = (this.headers["content-type"] || "");
106
+ if (!contentType.includes("multipart/form-data"))
107
+ return [];
108
+ if (this._filesCache !== null)
109
+ return this._filesCache;
110
+ await this.parseMultipart();
111
+ return this._filesCache;
112
+ }
113
+ /** Set the request body manually (e.g. after validation/sanitization). */
114
+ setBody(value) {
115
+ this._bodyCache = value;
116
+ this.storage.set("body", value);
117
+ }
118
+ async parseMultipart() {
119
+ if (this._bodyCache !== null && this._filesCache !== null)
120
+ return;
121
+ return new Promise((resolve, reject) => {
122
+ const bb = (0, busboy_1.default)({ headers: this.headers });
123
+ const fields = {};
124
+ const files = [];
125
+ bb.on("file", (name, file, info) => {
126
+ const chunks = [];
127
+ file.on("data", (data) => chunks.push(data));
128
+ file.on("end", () => {
129
+ files.push({
130
+ fieldname: name,
131
+ buffer: Buffer.concat(chunks),
132
+ ...info,
133
+ });
134
+ });
135
+ });
136
+ bb.on("field", (name, val) => {
137
+ fields[name] = val;
138
+ });
139
+ bb.on("close", () => {
140
+ this._bodyCache = fields;
141
+ this._filesCache = files;
142
+ resolve();
143
+ });
144
+ bb.on("error", (err) => reject(err));
145
+ this.req.pipe(bb);
146
+ });
147
+ }
148
+ /** Retrieve a value from per-request storage. */
149
+ get(key) {
150
+ return this.storage.get(key);
151
+ }
152
+ /** Store a value in per-request storage. */
153
+ set(key, value) {
154
+ this.storage.set(key, value);
155
+ }
156
+ /** Parse cookies from the `Cookie` header. */
157
+ cookies() {
158
+ if (this._cookies === null) {
159
+ const cookieHeader = this.headers.cookie;
160
+ const parsedCookies = cookieHeader ? (0, cookie_1.parse)(cookieHeader) : {};
161
+ this._cookies = parsedCookies;
162
+ }
163
+ return this._cookies || {};
164
+ }
165
+ /** Return a single cookie value by name. */
166
+ cookie(name) {
167
+ return this.cookies()[name];
168
+ }
169
+ /** Client IP address (considers `X-Forwarded-For` and `X-Real-IP`). */
170
+ ip() {
171
+ return (this.headers["x-forwarded-for"]?.split(",")[0]?.trim() ||
172
+ this.headers["x-real-ip"] ||
173
+ this.req.socket?.remoteAddress ||
174
+ "unknown");
175
+ }
176
+ /** `User-Agent` header value or empty string. */
177
+ userAgent() {
178
+ return this.headers["user-agent"] || "";
179
+ }
180
+ /** Return true when the request was made over TLS. */
181
+ isSecure() {
182
+ return (this.headers["x-forwarded-proto"] === "https" ||
183
+ this.req.socket?.encrypted === true);
184
+ }
185
+ /** Host header or `unknown` when missing. */
186
+ host() {
187
+ return this.headers.host || "unknown";
188
+ }
189
+ /** Full URL constructed from host and pathname. */
190
+ url() {
191
+ return `${this.isSecure() ? "https" : "http"}://${this.host()}${this.pathname}`;
192
+ }
193
+ }
194
+ exports.LithiaRequest = LithiaRequest;
195
+ function parseQueryToObject(raw) {
196
+ const obj = {};
197
+ for (const [k, v] of raw.entries()) {
198
+ if (obj[k] === undefined)
199
+ obj[k] = v;
200
+ else if (Array.isArray(obj[k]))
201
+ obj[k].push(v);
202
+ else
203
+ obj[k] = [obj[k], v];
204
+ }
205
+ return obj;
206
+ }
207
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/server/request.ts"],"names":[],"mappings":";;;;;;AA8OA,gDAQC;AArPD,oDAA+C;AAC/C,mCAA4D;AAiB5D;;;;;GAKG;AACH,MAAa,aAAa;IAmBP;IACA;IAnBlB,OAAO,CAAgC;IACvC,MAAM,CAAmB;IACzB,MAAM,CAAS;IACf,QAAQ,CAAmB;IAC3B,KAAK,CAAQ;IAEL,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IACrC,UAAU,GAAmB,IAAI,CAAC;IAClC,WAAW,GAA0B,IAAI,CAAC;IAC1C,QAAQ,GAAmB,IAAI,CAAC;IAExC;;;;;OAKG;IACH,YACkB,GAAoB,EACpB,MAAc;QADd,QAAG,GAAH,GAAG,CAAiB;QACpB,WAAM,GAAN,MAAM,CAAQ;QAE/B,MAAM,QAAQ,GACZ,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAY,KAAK,OAAO;YACvD,GAAG,CAAC,MAAc,EAAE,SAAS,KAAK,IAAI;YACtC,CAAC,CAAC,OAAO;YAC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I,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IACjF,CAAC;CACD;AAnND,sCAmNC;AAED,SAAgB,kBAAkB,CAAC,GAAoB;IACtD,MAAM,GAAG,GAAU,EAAE,CAAC;IACtB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;QACpC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;aAChC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAAG,GAAG,CAAC,CAAC,CAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;YACxD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAW,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -0,0 +1,69 @@
1
+ import type { OutgoingHttpHeaders, ServerResponse } from "node:http";
2
+ /** Options used when setting cookies on the response. */
3
+ export interface CookieOptions {
4
+ domain?: string;
5
+ expires?: Date;
6
+ httpOnly?: boolean;
7
+ maxAge?: number;
8
+ path?: string;
9
+ sameSite?: boolean | "lax" | "strict" | "none";
10
+ secure?: boolean;
11
+ }
12
+ /**
13
+ * High-level response wrapper used by Lithia handlers.
14
+ *
15
+ * This class wraps Node's `ServerResponse` and provides convenient helper
16
+ * methods for common response patterns used by Lithia handlers:
17
+ * - sending JSON (`json`), text/primitive bodies (`send`) and redirects
18
+ * - streaming static files (`sendFile`)
19
+ * - managing headers and queued cookies (`addHeader`, `setHeaders`, `cookie`)
20
+ *
21
+ * It also tracks whether the response has already been sent and will throw
22
+ * if you attempt to mutate the response after it was finalized.
23
+ *
24
+ * Instances are created per incoming request and are intended to be passed
25
+ * through middleware and route handlers.
26
+ */
27
+ export declare class LithiaResponse {
28
+ private res;
29
+ _ended: boolean;
30
+ private _cookies;
31
+ /** Create a new `LithiaResponse` wrapping a Node `ServerResponse`. */
32
+ constructor(res: ServerResponse);
33
+ /** Current HTTP status code for the response. */
34
+ get statusCode(): number;
35
+ /** Convenience passthrough to the underlying `ServerResponse#on`. */
36
+ on: (event: string, listener: (chunk: unknown) => void) => void;
37
+ private checkIfEnded;
38
+ /** Set the numeric HTTP status code. */
39
+ status(status: number): LithiaResponse;
40
+ /** Return a copy of currently set headers. */
41
+ headers(): Readonly<OutgoingHttpHeaders>;
42
+ /** Replace multiple headers at once. */
43
+ setHeaders(headers: OutgoingHttpHeaders): LithiaResponse;
44
+ /** Set a single header. */
45
+ addHeader(name: string, value: string | number | string[]): LithiaResponse;
46
+ /** Remove a header if present. */
47
+ removeHeader(name: string): LithiaResponse;
48
+ /** End the response without a body. */
49
+ end(): void;
50
+ /** Send an object as JSON. Sets `Content-Type: application/json`. */
51
+ json(obj: object): void;
52
+ /** Send an HTTP redirect to `url`. */
53
+ redirect(url: string, status?: number): void;
54
+ /**
55
+ * Send a response body.
56
+ * - `Buffer` bodies are sent as `application/octet-stream`.
57
+ * - Objects are serialized as JSON.
58
+ * - Primitives are sent as text/plain.
59
+ */
60
+ send(data?: unknown): void;
61
+ /** Queue a cookie to be set on the response. */
62
+ cookie(name: string, value: string, options?: CookieOptions): LithiaResponse;
63
+ /** Clear a cookie by setting it with an expired date. */
64
+ clearCookie(name: string, options?: CookieOptions): LithiaResponse;
65
+ /** Send a static file from disk. `opts.root` may be used to resolve relative paths. */
66
+ sendFile(filePath: string, opts?: {
67
+ root?: string;
68
+ }): void;
69
+ }
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LithiaResponse = void 0;
4
+ const node_fs_1 = require("node:fs");
5
+ const node_path_1 = require("node:path");
6
+ const cookie_1 = require("cookie");
7
+ const logger_1 = require("../logger");
8
+ /**
9
+ * High-level response wrapper used by Lithia handlers.
10
+ *
11
+ * This class wraps Node's `ServerResponse` and provides convenient helper
12
+ * methods for common response patterns used by Lithia handlers:
13
+ * - sending JSON (`json`), text/primitive bodies (`send`) and redirects
14
+ * - streaming static files (`sendFile`)
15
+ * - managing headers and queued cookies (`addHeader`, `setHeaders`, `cookie`)
16
+ *
17
+ * It also tracks whether the response has already been sent and will throw
18
+ * if you attempt to mutate the response after it was finalized.
19
+ *
20
+ * Instances are created per incoming request and are intended to be passed
21
+ * through middleware and route handlers.
22
+ */
23
+ class LithiaResponse {
24
+ res;
25
+ _ended = false;
26
+ _cookies = [];
27
+ /** Create a new `LithiaResponse` wrapping a Node `ServerResponse`. */
28
+ constructor(res) {
29
+ this.res = res;
30
+ this.on = this.res.on.bind(this.res);
31
+ }
32
+ /** Current HTTP status code for the response. */
33
+ get statusCode() {
34
+ return this.res.statusCode;
35
+ }
36
+ /** Convenience passthrough to the underlying `ServerResponse#on`. */
37
+ on;
38
+ checkIfEnded() {
39
+ if (this._ended)
40
+ throw new Error("Cannot modify response after it was sent");
41
+ }
42
+ /** Set the numeric HTTP status code. */
43
+ status(status) {
44
+ this.checkIfEnded();
45
+ if (status < 100 || status > 599)
46
+ throw new Error("Invalid HTTP status code");
47
+ this.res.statusCode = status;
48
+ return this;
49
+ }
50
+ /** Return a copy of currently set headers. */
51
+ headers() {
52
+ return this.res.getHeaders();
53
+ }
54
+ /** Replace multiple headers at once. */
55
+ setHeaders(headers) {
56
+ this.checkIfEnded();
57
+ Object.entries(headers).forEach(([k, v]) => {
58
+ this.res.setHeader(k, v);
59
+ });
60
+ return this;
61
+ }
62
+ /** Set a single header. */
63
+ addHeader(name, value) {
64
+ this.checkIfEnded();
65
+ this.res.setHeader(name, value);
66
+ return this;
67
+ }
68
+ /** Remove a header if present. */
69
+ removeHeader(name) {
70
+ this.checkIfEnded();
71
+ this.res.removeHeader(name);
72
+ return this;
73
+ }
74
+ /** End the response without a body. */
75
+ end() {
76
+ this.checkIfEnded();
77
+ this.res.end();
78
+ this._ended = true;
79
+ }
80
+ /** Send an object as JSON. Sets `Content-Type: application/json`. */
81
+ json(obj) {
82
+ this.checkIfEnded();
83
+ try {
84
+ const body = JSON.stringify(obj);
85
+ this.res.setHeader("Content-Type", "application/json; charset=utf-8");
86
+ this.res.end(body);
87
+ }
88
+ catch (err) {
89
+ logger_1.logger.error("Failed to serialize JSON response:", err);
90
+ this.res.statusCode = 500;
91
+ this.res.end("Internal Server Error");
92
+ }
93
+ finally {
94
+ this._ended = true;
95
+ }
96
+ }
97
+ /** Send an HTTP redirect to `url`. */
98
+ redirect(url, status = 302) {
99
+ this.checkIfEnded();
100
+ this.status(status).addHeader("Location", url).end();
101
+ }
102
+ /**
103
+ * Send a response body.
104
+ * - `Buffer` bodies are sent as `application/octet-stream`.
105
+ * - Objects are serialized as JSON.
106
+ * - Primitives are sent as text/plain.
107
+ */
108
+ send(data) {
109
+ // Set cookies first
110
+ if (this._cookies.length > 0) {
111
+ const existing = this.res.getHeader("Set-Cookie") || [];
112
+ const serialized = this._cookies.map((c) => (0, cookie_1.serialize)(c.name, c.value, c.options));
113
+ this.res.setHeader("Set-Cookie", [...existing, ...serialized]);
114
+ this._cookies = [];
115
+ }
116
+ this.checkIfEnded();
117
+ try {
118
+ if (data === undefined || data === null) {
119
+ this.end();
120
+ return;
121
+ }
122
+ if (Buffer.isBuffer(data)) {
123
+ if (!this.res.getHeader("Content-Type"))
124
+ this.addHeader("Content-Type", "application/octet-stream");
125
+ this.res.end(data);
126
+ }
127
+ else if (typeof data === "object") {
128
+ this.json(data);
129
+ }
130
+ else {
131
+ if (!this.res.getHeader("Content-Type"))
132
+ this.addHeader("Content-Type", "text/plain; charset=utf-8");
133
+ this.res.end(String(data));
134
+ }
135
+ }
136
+ finally {
137
+ this._ended = true;
138
+ }
139
+ }
140
+ /** Queue a cookie to be set on the response. */
141
+ cookie(name, value, options = {}) {
142
+ this.checkIfEnded();
143
+ this._cookies.push({ name, value, options });
144
+ return this;
145
+ }
146
+ /** Clear a cookie by setting it with an expired date. */
147
+ clearCookie(name, options = {}) {
148
+ this.checkIfEnded();
149
+ return this.cookie(name, "", { ...options, expires: new Date(0) });
150
+ }
151
+ /** Send a static file from disk. `opts.root` may be used to resolve relative paths. */
152
+ sendFile(filePath, opts = {}) {
153
+ this.checkIfEnded();
154
+ try {
155
+ const full = opts.root ? (0, node_path_1.join)(opts.root, filePath) : filePath;
156
+ const stats = (0, node_fs_1.statSync)(full);
157
+ if (!stats.isFile())
158
+ throw new Error("Not a file");
159
+ this.addHeader("Content-Length", String(stats.size));
160
+ const stream = (0, node_fs_1.createReadStream)(full);
161
+ stream.pipe(this.res);
162
+ stream.on("error", () => this.status(404).send({ error: "File not found" }));
163
+ }
164
+ catch {
165
+ this.status(404).send({ error: "File not found" });
166
+ }
167
+ finally {
168
+ this._ended = true;
169
+ }
170
+ }
171
+ }
172
+ exports.LithiaResponse = LithiaResponse;
173
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/server/response.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AAErD,yCAAiC;AACjC,mCAAsD;AACtD,sCAAmC;AAanC;;;;;;;;;;;;;;GAcG;AACH,MAAa,cAAc;IASN;IARpB,MAAM,GAAG,KAAK,CAAC;IACP,QAAQ,GAIX,EAAE,CAAC;IAER,sEAAsE;IACtE,YAAoB,GAAmB;QAAnB,QAAG,GAAH,GAAG,CAAgB;QACtC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IAED,iDAAiD;IACjD,IAAI,UAAU;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;IAC5B,CAAC;IAED,qEAAqE;IACrE,EAAE,CAA8D;IAExD,YAAY;QACnB,IAAI,IAAI,CAAC,MAAM;YACd,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;I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BAAS,CAAC;YACV,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACpB,CAAC;IACF,CAAC;CACD;AA3KD,wCA2KC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@lithia-js/core",
3
+ "version": "1.0.0-canary.0",
4
+ "private": false,
5
+ "main": "dist/lib.js",
6
+ "types": "dist/lib.d.ts",
7
+ "author": "Lucas Arch <luketsx@icloud.com>",
8
+ "homepage": "https://lithiajs.com",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/lithia-framework/lithia.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/lithia-framework/lithia/issues"
16
+ },
17
+ "devDependencies": {
18
+ "@types/busboy": "^1.5.4",
19
+ "@types/source-map-support": "^0.5.10"
20
+ },
21
+ "dependencies": {
22
+ "busboy": "^1.6.0",
23
+ "c12": "^3.3.3",
24
+ "cookie": "^1.1.1",
25
+ "import-fresh": "^3.3.1",
26
+ "klona": "^2.0.6",
27
+ "socket.io": "^4.8.1",
28
+ "source-map-support": "^0.5.21",
29
+ "zod": "^4.2.1",
30
+ "@lithia-js/utils": "1.0.0-canary.0",
31
+ "@lithia-js/native": "1.0.0-canary.0"
32
+ },
33
+ "engines": {
34
+ "node": ">=20"
35
+ },
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/lib.d.ts",
39
+ "require": "./dist/lib.js",
40
+ "import": "./dist/lib.js"
41
+ }
42
+ },
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.build.json"
45
+ }
46
+ }