@darthcav/ts-http-server 0.0.1

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 (65) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +118 -0
  3. package/dist/__tests__/launcher.test.d.ts +2 -0
  4. package/dist/__tests__/launcher.test.d.ts.map +1 -0
  5. package/dist/__tests__/launcher.test.js +116 -0
  6. package/dist/__tests__/launcher.test.js.map +1 -0
  7. package/dist/defaults/defaultErrorHandler.d.ts +14 -0
  8. package/dist/defaults/defaultErrorHandler.d.ts.map +1 -0
  9. package/dist/defaults/defaultErrorHandler.js +58 -0
  10. package/dist/defaults/defaultErrorHandler.js.map +1 -0
  11. package/dist/defaults/defaultFastifyOptions.d.ts +18 -0
  12. package/dist/defaults/defaultFastifyOptions.d.ts.map +1 -0
  13. package/dist/defaults/defaultFastifyOptions.js +25 -0
  14. package/dist/defaults/defaultFastifyOptions.js.map +1 -0
  15. package/dist/defaults/defaultPlugins.d.ts +19 -0
  16. package/dist/defaults/defaultPlugins.d.ts.map +1 -0
  17. package/dist/defaults/defaultPlugins.js +84 -0
  18. package/dist/defaults/defaultPlugins.js.map +1 -0
  19. package/dist/defaults/defaultRoutes.d.ts +10 -0
  20. package/dist/defaults/defaultRoutes.d.ts.map +1 -0
  21. package/dist/defaults/defaultRoutes.js +38 -0
  22. package/dist/defaults/defaultRoutes.js.map +1 -0
  23. package/dist/defaults/getConsoleFastifyLogger.d.ts +15 -0
  24. package/dist/defaults/getConsoleFastifyLogger.d.ts.map +1 -0
  25. package/dist/defaults/getConsoleFastifyLogger.js +20 -0
  26. package/dist/defaults/getConsoleFastifyLogger.js.map +1 -0
  27. package/dist/hooks/onResponse.d.ts +18 -0
  28. package/dist/hooks/onResponse.d.ts.map +1 -0
  29. package/dist/hooks/onResponse.js +26 -0
  30. package/dist/hooks/onResponse.js.map +1 -0
  31. package/dist/hooks/preHandler.d.ts +18 -0
  32. package/dist/hooks/preHandler.d.ts.map +1 -0
  33. package/dist/hooks/preHandler.js +19 -0
  34. package/dist/hooks/preHandler.js.map +1 -0
  35. package/dist/index.d.ts +15 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +14 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/launcher.d.ts +17 -0
  40. package/dist/launcher.d.ts.map +1 -0
  41. package/dist/launcher.js +55 -0
  42. package/dist/launcher.js.map +1 -0
  43. package/dist/start.d.ts +2 -0
  44. package/dist/start.d.ts.map +1 -0
  45. package/dist/start.js +24 -0
  46. package/dist/start.js.map +1 -0
  47. package/dist/types.d.ts +46 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +2 -0
  50. package/dist/types.js.map +1 -0
  51. package/package.json +78 -0
  52. package/src/__tests__/launcher.test.ts +136 -0
  53. package/src/defaults/defaultErrorHandler.ts +69 -0
  54. package/src/defaults/defaultFastifyOptions.ts +29 -0
  55. package/src/defaults/defaultPlugins.ts +90 -0
  56. package/src/defaults/defaultRoutes.ts +42 -0
  57. package/src/defaults/getConsoleFastifyLogger.ts +27 -0
  58. package/src/hooks/onResponse.ts +34 -0
  59. package/src/hooks/preHandler.ts +25 -0
  60. package/src/index.ts +28 -0
  61. package/src/launcher.ts +74 -0
  62. package/src/public/README.md +3 -0
  63. package/src/start.ts +30 -0
  64. package/src/types.ts +55 -0
  65. package/src/views/README.md +3 -0
@@ -0,0 +1,84 @@
1
+ import { join } from "node:path";
2
+ import FastifyAccepts from "@fastify/accepts";
3
+ import FastifyCompress from "@fastify/compress";
4
+ import FastifyCors from "@fastify/cors";
5
+ import FastifyEtag from "@fastify/etag";
6
+ import FastifyHelmet from "@fastify/helmet";
7
+ import FastifyStatic from "@fastify/static";
8
+ import FastifyView from "@fastify/view";
9
+ import Ejs from "ejs";
10
+ /**
11
+ * Builds the default plugin map for use with `launcher`.
12
+ *
13
+ * Registers: `@fastify/accepts`, `@fastify/compress`,
14
+ * `@fastify/cors`, `@fastify/etag`, `@fastify/helmet`,
15
+ * `@fastify/view` (EJS), and `@fastify/static`.
16
+ *
17
+ * @param opts.locals - Application locals; `locals.pkg` is exposed as the
18
+ * default context for every EJS view.
19
+ * @param opts.baseDir - Optional base directory for resolving the `src/` folder; defaults to the parent of `import.meta.dirname`.
20
+ * @returns A `Map` of plugin names to plugin entries, suitable for passing as
21
+ * the `plugins` field of `LauncherOptions`.
22
+ */
23
+ export default function defaultPlugins(opts) {
24
+ const { locals, baseDir = null } = opts;
25
+ const plugins = new Map();
26
+ const srcDir = baseDir
27
+ ? join(baseDir, "src")
28
+ : join(import.meta.dirname, "..");
29
+ plugins.set("@fastify/accepts", {
30
+ plugin: FastifyAccepts,
31
+ });
32
+ plugins.set("@fastify/compress", {
33
+ plugin: FastifyCompress,
34
+ });
35
+ plugins.set("@fastify/cors", {
36
+ plugin: FastifyCors,
37
+ opts: { origin: true },
38
+ });
39
+ plugins.set("@fastify/etag", {
40
+ plugin: FastifyEtag,
41
+ opts: { algorithm: "sha1" },
42
+ });
43
+ plugins.set("@fastify/helmet", {
44
+ plugin: FastifyHelmet,
45
+ opts: {
46
+ global: true,
47
+ contentSecurityPolicy: {
48
+ directives: {
49
+ fontSrc: [
50
+ "'self'",
51
+ "https://fonts.googleapis.com/",
52
+ "https://fonts.gstatic.com/",
53
+ ],
54
+ scriptSrc: [
55
+ "'self'",
56
+ "'unsafe-inline'",
57
+ "https://cdn.jsdelivr.net/",
58
+ ],
59
+ },
60
+ },
61
+ hsts: {
62
+ maxAge: 31536000,
63
+ includeSubDomains: true,
64
+ },
65
+ },
66
+ });
67
+ plugins.set("@fastify/view", {
68
+ plugin: FastifyView,
69
+ opts: {
70
+ engine: { ejs: Ejs },
71
+ root: join(srcDir, "views"),
72
+ defaultContext: { pkg: locals.pkg },
73
+ },
74
+ });
75
+ plugins.set("@fastify/static", {
76
+ plugin: FastifyStatic,
77
+ opts: {
78
+ root: join(srcDir, "public"),
79
+ prefix: "/",
80
+ },
81
+ });
82
+ return plugins;
83
+ }
84
+ //# sourceMappingURL=defaultPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultPlugins.js","sourceRoot":"","sources":["../../src/defaults/defaultPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,GAAG,MAAM,KAAK,CAAA;AAGrB;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,IAGtC;IACG,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,IAAI,CAAA;IACvC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAqB,CAAA;IAC5C,MAAM,MAAM,GAAG,OAAO;QAClB,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QACtB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAErC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE;QAC5B,MAAM,EAAE,cAAc;KACzB,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;QAC7B,MAAM,EAAE,eAAe;KAC1B,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE;QACzB,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;KACzB,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE;QACzB,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;KAC9B,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;QAC3B,MAAM,EAAE,aAAa;QACrB,IAAI,EAAE;YACF,MAAM,EAAE,IAAI;YACZ,qBAAqB,EAAE;gBACnB,UAAU,EAAE;oBACR,OAAO,EAAE;wBACL,QAAQ;wBACR,+BAA+B;wBAC/B,4BAA4B;qBAC/B;oBACD,SAAS,EAAE;wBACP,QAAQ;wBACR,iBAAiB;wBACjB,2BAA2B;qBAC9B;iBACJ;aACJ;YACD,IAAI,EAAE;gBACF,MAAM,EAAE,QAAQ;gBAChB,iBAAiB,EAAE,IAAI;aAC1B;SACJ;KACJ,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE;QACzB,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE;YACF,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE;YACpB,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;YAC3B,cAAc,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE;SACtC;KACJ,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;QAC3B,MAAM,EAAE,aAAa;QACrB,IAAI,EAAE;YACF,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC;YAC5B,MAAM,EAAE,GAAG;SACd;KACJ,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAClB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { RouteOptions } from "fastify";
2
+ /**
3
+ * Returns the default route map used in {@link launcher}.
4
+ *
5
+ * Registers:
6
+ * - `GET /` — renders `index.ejs` for `text/html`, throws 406 otherwise.
7
+ * - `DELETE|PATCH|POST|PUT|OPTIONS /` — responds with 405 Method Not Allowed.
8
+ */
9
+ export default function defaultRoutes(): Map<string, RouteOptions>;
10
+ //# sourceMappingURL=defaultRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultRoutes.d.ts","sourceRoot":"","sources":["../../src/defaults/defaultRoutes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CA+BjE"}
@@ -0,0 +1,38 @@
1
+ import { methodNotAllowed, notAcceptable } from "@hapi/boom";
2
+ /**
3
+ * Returns the default route map used in {@link launcher}.
4
+ *
5
+ * Registers:
6
+ * - `GET /` — renders `index.ejs` for `text/html`, throws 406 otherwise.
7
+ * - `DELETE|PATCH|POST|PUT|OPTIONS /` — responds with 405 Method Not Allowed.
8
+ */
9
+ export default function defaultRoutes() {
10
+ const routes = new Map();
11
+ routes.set("INDEX", {
12
+ method: "GET",
13
+ url: "/",
14
+ exposeHeadRoute: true,
15
+ handler: async (request, reply) => {
16
+ const accept = request.accepts();
17
+ switch (accept.type(["html"])) {
18
+ case "html":
19
+ return reply.type("text/html").view("index.ejs", {
20
+ menu_name: "index",
21
+ header: "Welcome page",
22
+ });
23
+ default:
24
+ throw notAcceptable();
25
+ }
26
+ },
27
+ });
28
+ routes.set("INDEX_405", {
29
+ method: ["DELETE", "PATCH", "POST", "PUT", "OPTIONS"],
30
+ url: "/",
31
+ handler: async (_request, reply) => {
32
+ reply.header("allow", "GET, HEAD");
33
+ throw methodNotAllowed();
34
+ },
35
+ });
36
+ return routes;
37
+ }
38
+ //# sourceMappingURL=defaultRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultRoutes.js","sourceRoot":"","sources":["../../src/defaults/defaultRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAG5D;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa;IACjC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAA;IAE9C,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG;QACR,eAAe,EAAE,IAAI;QACrB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;YAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAA;YAChC,QAAQ,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;gBAC5B,KAAK,MAAM;oBACP,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE;wBAC7C,SAAS,EAAE,OAAO;wBAClB,MAAM,EAAE,cAAc;qBACzB,CAAC,CAAA;gBACN;oBACI,MAAM,aAAa,EAAE,CAAA;YAC7B,CAAC;QACL,CAAC;KACJ,CAAC,CAAA;IAEF,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE;QACpB,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC;QACrD,GAAG,EAAE,GAAG;QACR,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;YAC/B,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;YAClC,MAAM,gBAAgB,EAAE,CAAA;QAC5B,CAAC;KACJ,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACjB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type PinoLevel, type PinoLikeLogger } from "@logtape/fastify";
2
+ /**
3
+ * Returns a `PinoLikeLogger` for Fastify scoped to the given category.
4
+ *
5
+ * Assumes LogTape has already been configured by the caller (e.g. via
6
+ * `getConsoleLogger`). All records at or above `level` are forwarded
7
+ * by Fastify to the active LogTape sinks.
8
+ *
9
+ * @param name - Logger category array passed to `getLogTapeFastifyLogger`
10
+ * (e.g. `["my-app", "fastify"]`).
11
+ * @param level - Minimum Pino log level to pass through. Defaults to `"info"`.
12
+ * @returns A Pino-compatible logger backed by LogTape.
13
+ */
14
+ export default function getConsoleFastifyLogger(name: string[], level?: PinoLevel): PinoLikeLogger;
15
+ //# sourceMappingURL=getConsoleFastifyLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getConsoleFastifyLogger.d.ts","sourceRoot":"","sources":["../../src/defaults/getConsoleFastifyLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,SAAS,EACd,KAAK,cAAc,EACtB,MAAM,kBAAkB,CAAA;AAEzB;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,GAAE,SAAkB,GAC1B,cAAc,CAKhB"}
@@ -0,0 +1,20 @@
1
+ import { getLogTapeFastifyLogger, } from "@logtape/fastify";
2
+ /**
3
+ * Returns a `PinoLikeLogger` for Fastify scoped to the given category.
4
+ *
5
+ * Assumes LogTape has already been configured by the caller (e.g. via
6
+ * `getConsoleLogger`). All records at or above `level` are forwarded
7
+ * by Fastify to the active LogTape sinks.
8
+ *
9
+ * @param name - Logger category array passed to `getLogTapeFastifyLogger`
10
+ * (e.g. `["my-app", "fastify"]`).
11
+ * @param level - Minimum Pino log level to pass through. Defaults to `"info"`.
12
+ * @returns A Pino-compatible logger backed by LogTape.
13
+ */
14
+ export default function getConsoleFastifyLogger(name, level = "info") {
15
+ return getLogTapeFastifyLogger({
16
+ category: name,
17
+ level,
18
+ });
19
+ }
20
+ //# sourceMappingURL=getConsoleFastifyLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getConsoleFastifyLogger.js","sourceRoot":"","sources":["../../src/defaults/getConsoleFastifyLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,GAG1B,MAAM,kBAAkB,CAAA;AAEzB;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC3C,IAAc,EACd,QAAmB,MAAM;IAEzB,OAAO,uBAAuB,CAAC;QAC3B,QAAQ,EAAE,IAAI;QACd,KAAK;KACR,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { FastifyReply, FastifyRequest } from "fastify";
2
+ /**
3
+ * Fastify `onResponse` hook that logs completed request details:
4
+ *
5
+ * ```
6
+ * {ip} -- {method} {url} HTTP/{httpVersion} {status} {size} {elapsed}ms "{referrer}" "{userAgent}"
7
+ * ```
8
+ *
9
+ * Intended to be registered via:
10
+ * ```ts
11
+ * fastify.addHook("onResponse", onResponse)
12
+ * ```
13
+ *
14
+ * Uses `reply.log.info` so each log record is automatically correlated with
15
+ * the request ID assigned by Fastify.
16
+ */
17
+ export default function onResponse(request: FastifyRequest, reply: FastifyReply): Promise<void>;
18
+ //# sourceMappingURL=onResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onResponse.d.ts","sourceRoot":"","sources":["../../src/hooks/onResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE3D;;;;;;;;;;;;;;GAcG;AACH,wBAA8B,UAAU,CACpC,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAaf"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Fastify `onResponse` hook that logs completed request details:
3
+ *
4
+ * ```
5
+ * {ip} -- {method} {url} HTTP/{httpVersion} {status} {size} {elapsed}ms "{referrer}" "{userAgent}"
6
+ * ```
7
+ *
8
+ * Intended to be registered via:
9
+ * ```ts
10
+ * fastify.addHook("onResponse", onResponse)
11
+ * ```
12
+ *
13
+ * Uses `reply.log.info` so each log record is automatically correlated with
14
+ * the request ID assigned by Fastify.
15
+ */
16
+ export default async function onResponse(request, reply) {
17
+ const contentLength = reply.getHeader("content-length");
18
+ const size = contentLength != null ? Number(contentLength) : "-";
19
+ if (reply.statusCode < 400) {
20
+ reply.log.info(`${request.ip} -- ${request.method} ${request.url} HTTP/${request.raw.httpVersion} ${reply.statusCode} ${size} ${Math.round(reply.elapsedTime)}ms "${request.headers["referer"] ?? "-"}" "${request.headers["user-agent"] ?? "-"}"`);
21
+ }
22
+ else {
23
+ reply.log.error(`${request.ip} -- ${request.method} ${request.url} HTTP/${request.raw.httpVersion} ${reply.statusCode} ${size} ${Math.round(reply.elapsedTime)}ms "${request.headers["referer"] ?? "-"}" "${request.headers["user-agent"] ?? "-"}"`);
24
+ }
25
+ }
26
+ //# sourceMappingURL=onResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onResponse.js","sourceRoot":"","sources":["../../src/hooks/onResponse.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,UAAU,CACpC,OAAuB,EACvB,KAAmB;IAEnB,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAA;IACvD,MAAM,IAAI,GAAG,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IAEhE,IAAI,KAAK,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC;QACzB,KAAK,CAAC,GAAG,CAAC,IAAI,CACV,GAAG,OAAO,CAAC,EAAE,OAAO,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,GAAG,GAAG,CACtO,CAAA;IACL,CAAC;SAAM,CAAC;QACJ,KAAK,CAAC,GAAG,CAAC,KAAK,CACX,GAAG,OAAO,CAAC,EAAE,OAAO,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,GAAG,GAAG,CACtO,CAAA;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { FastifyReply, FastifyRequest } from "fastify";
2
+ /**
3
+ * Fastify `preHandler` hook that logs incoming request details:
4
+ *
5
+ * ```
6
+ * Incoming request: {method} {url} HTTP/{httpVersion} from {ip}
7
+ * ```
8
+ *
9
+ * Intended to be registered via:
10
+ * ```ts
11
+ * fastify.addHook("preHandler", preHandler)
12
+ * ```
13
+ *
14
+ * Uses `request.log.info` so each log record is automatically correlated with
15
+ * the request ID assigned by Fastify.
16
+ */
17
+ export default function preHandler(request: FastifyRequest, _reply: FastifyReply): Promise<void>;
18
+ //# sourceMappingURL=preHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preHandler.d.ts","sourceRoot":"","sources":["../../src/hooks/preHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE3D;;;;;;;;;;;;;;GAcG;AACH,wBAA8B,UAAU,CACpC,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,YAAY,GACrB,OAAO,CAAC,IAAI,CAAC,CAIf"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Fastify `preHandler` hook that logs incoming request details:
3
+ *
4
+ * ```
5
+ * Incoming request: {method} {url} HTTP/{httpVersion} from {ip}
6
+ * ```
7
+ *
8
+ * Intended to be registered via:
9
+ * ```ts
10
+ * fastify.addHook("preHandler", preHandler)
11
+ * ```
12
+ *
13
+ * Uses `request.log.info` so each log record is automatically correlated with
14
+ * the request ID assigned by Fastify.
15
+ */
16
+ export default async function preHandler(request, _reply) {
17
+ request.log.debug(`Incoming request [${request.id}]: ${request.method} ${request.url} HTTP/${request.raw.httpVersion} from ${request.ip}`);
18
+ }
19
+ //# sourceMappingURL=preHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preHandler.js","sourceRoot":"","sources":["../../src/hooks/preHandler.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,UAAU,CACpC,OAAuB,EACvB,MAAoB;IAEpB,OAAO,CAAC,GAAG,CAAC,KAAK,CACb,qBAAqB,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC,GAAG,CAAC,WAAW,SAAS,OAAO,CAAC,EAAE,EAAE,CAC1H,CAAA;AACL,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A TypeScript HTTP server library built on Fastify for Node.js >= 25.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import defaultErrorHandler from "./defaults/defaultErrorHandler.ts";
7
+ import defaultFastifyOptions from "./defaults/defaultFastifyOptions.ts";
8
+ import defaultPlugins from "./defaults/defaultPlugins.ts";
9
+ import defaultRoutes from "./defaults/defaultRoutes.ts";
10
+ import onResponse from "./hooks/onResponse.ts";
11
+ import preHandler from "./hooks/preHandler.ts";
12
+ import launcher from "./launcher.ts";
13
+ export type { FSTPlugin, LauncherLocals, LauncherOptions, } from "./types.ts";
14
+ export { defaultErrorHandler, defaultFastifyOptions, defaultPlugins, defaultRoutes, launcher, preHandler, onResponse, };
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,mBAAmB,MAAM,mCAAmC,CAAA;AACnE,OAAO,qBAAqB,MAAM,qCAAqC,CAAA;AACvE,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,UAAU,MAAM,uBAAuB,CAAA;AAC9C,OAAO,UAAU,MAAM,uBAAuB,CAAA;AAC9C,OAAO,QAAQ,MAAM,eAAe,CAAA;AAEpC,YAAY,EACR,SAAS,EACT,cAAc,EACd,eAAe,GAClB,MAAM,YAAY,CAAA;AACnB,OAAO,EACH,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,QAAQ,EACR,UAAU,EACV,UAAU,GACb,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A TypeScript HTTP server library built on Fastify for Node.js >= 25.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import defaultErrorHandler from "./defaults/defaultErrorHandler.js";
7
+ import defaultFastifyOptions from "./defaults/defaultFastifyOptions.js";
8
+ import defaultPlugins from "./defaults/defaultPlugins.js";
9
+ import defaultRoutes from "./defaults/defaultRoutes.js";
10
+ import onResponse from "./hooks/onResponse.js";
11
+ import preHandler from "./hooks/preHandler.js";
12
+ import launcher from "./launcher.js";
13
+ export { defaultErrorHandler, defaultFastifyOptions, defaultPlugins, defaultRoutes, launcher, preHandler, onResponse, };
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,mBAAmB,MAAM,mCAAmC,CAAA;AACnE,OAAO,qBAAqB,MAAM,qCAAqC,CAAA;AACvE,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,UAAU,MAAM,uBAAuB,CAAA;AAC9C,OAAO,UAAU,MAAM,uBAAuB,CAAA;AAC9C,OAAO,QAAQ,MAAM,eAAe,CAAA;AAOpC,OAAO,EACH,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,QAAQ,EACR,UAAU,EACV,UAAU,GACb,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { type FastifyInstance } from "fastify";
2
+ import type { LauncherOptions } from "./types.ts";
3
+ /**
4
+ * Creates and starts a Fastify HTTP server with the given configuration.
5
+ *
6
+ * Steps performed:
7
+ * 1. Creates a `FastifyInstance` merging {@link defaultFastifyOptions} with `opts`.
8
+ * 2. Decorates the instance with `locals` and any extra `decorators`.
9
+ * 3. Registers all `plugins` and `routes`.
10
+ * 4. Sets a `notFound` handler (throws Boom 404) and {@link defaultErrorHandler}.
11
+ * 5. Registers {@link preHandler} and {@link onResponse} hooks.
12
+ * 6. Calls `fastify.listen()` and invokes the optional `done` callback.
13
+ *
14
+ * @returns The `FastifyInstance` (e.g. for use with `fastify.close()`).
15
+ */
16
+ export default function launcher({ logger, locals, plugins, routes, decorators, opts, done, }: LauncherOptions): FastifyInstance;
17
+ //# sourceMappingURL=launcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAEA,OAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAIvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC7B,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,UAAU,EACV,IAAI,EACJ,IAAI,GACP,EAAE,eAAe,GAAG,eAAe,CA4CnC"}
@@ -0,0 +1,55 @@
1
+ import process, { env } from "node:process";
2
+ import { notFound } from "@hapi/boom";
3
+ import Fastify, {} from "fastify";
4
+ import defaultErrorHandler from "./defaults/defaultErrorHandler.js";
5
+ import defaultFastifyOptions from "./defaults/defaultFastifyOptions.js";
6
+ import { onResponse, preHandler } from "./index.js";
7
+ /**
8
+ * Creates and starts a Fastify HTTP server with the given configuration.
9
+ *
10
+ * Steps performed:
11
+ * 1. Creates a `FastifyInstance` merging {@link defaultFastifyOptions} with `opts`.
12
+ * 2. Decorates the instance with `locals` and any extra `decorators`.
13
+ * 3. Registers all `plugins` and `routes`.
14
+ * 4. Sets a `notFound` handler (throws Boom 404) and {@link defaultErrorHandler}.
15
+ * 5. Registers {@link preHandler} and {@link onResponse} hooks.
16
+ * 6. Calls `fastify.listen()` and invokes the optional `done` callback.
17
+ *
18
+ * @returns The `FastifyInstance` (e.g. for use with `fastify.close()`).
19
+ */
20
+ export default function launcher({ logger, locals, plugins, routes, decorators, opts, done, }) {
21
+ const host = locals?.host ?? "localhost";
22
+ const port = locals?.port ?? Number(env["CONTAINER_EXPOSE_PORT"] ?? 8888);
23
+ const fastify = Fastify({
24
+ ...defaultFastifyOptions(logger),
25
+ ...opts,
26
+ });
27
+ fastify.decorate("locals", locals);
28
+ if (decorators instanceof Map) {
29
+ for (const [key, value] of decorators) {
30
+ fastify.decorate(key, value);
31
+ }
32
+ }
33
+ for (const value of plugins.values()) {
34
+ void fastify.register(value.plugin, value.opts ?? {});
35
+ }
36
+ for (const value of routes.values()) {
37
+ fastify.route(value);
38
+ }
39
+ fastify.setNotFoundHandler(async (_request, _reply) => {
40
+ throw notFound();
41
+ });
42
+ fastify.setErrorHandler(defaultErrorHandler);
43
+ // TODO: Add hook for `onRequestAbort`
44
+ fastify.addHook("preHandler", preHandler);
45
+ fastify.addHook("onResponse", onResponse);
46
+ fastify.listen({ host, port }, (error) => {
47
+ if (error) {
48
+ logger.error(`${error.message}`);
49
+ process.exit(1);
50
+ }
51
+ done?.();
52
+ });
53
+ return fastify;
54
+ }
55
+ //# sourceMappingURL=launcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launcher.js","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,OAAO,EAAE,EAAwB,MAAM,SAAS,CAAA;AACvD,OAAO,mBAAmB,MAAM,mCAAmC,CAAA;AACnE,OAAO,qBAAqB,MAAM,qCAAqC,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGnD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC7B,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,UAAU,EACV,IAAI,EACJ,IAAI,GACU;IACd,MAAM,IAAI,GAAG,MAAM,EAAE,IAAI,IAAI,WAAW,CAAA;IACxC,MAAM,IAAI,GAAG,MAAM,EAAE,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,IAAI,CAAC,CAAA;IAEzE,MAAM,OAAO,GAAG,OAAO,CAAC;QACpB,GAAG,qBAAqB,CAAC,MAAM,CAAC;QAChC,GAAG,IAAI;KACV,CAAC,CAAA;IAEF,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAElC,IAAI,UAAU,YAAY,GAAG,EAAE,CAAC;QAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,UAAU,EAAE,CAAC;YACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAChC,CAAC;IACL,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QACnC,KAAK,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;IACzD,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC;IAED,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;QAClD,MAAM,QAAQ,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAA;IAE5C,sCAAsC;IACtC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;IACzC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;IAEzC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;QACrC,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAChC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;QACD,IAAI,EAAE,EAAE,CAAA;IACZ,CAAC,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":""}
package/dist/start.js ADDED
@@ -0,0 +1,24 @@
1
+ import process from "node:process";
2
+ import { getConsoleLogger, main } from "@darthcav/ts-utils";
3
+ import pkg from "../package.json" with { type: "json" };
4
+ import { defaultPlugins, defaultRoutes, launcher } from "./index.js";
5
+ const logger = await getConsoleLogger(pkg.name, "info");
6
+ main(pkg.name, logger, false, () => {
7
+ const locals = { pkg };
8
+ const plugins = defaultPlugins({ locals });
9
+ const routes = defaultRoutes();
10
+ const fastify = launcher({ logger, locals, plugins, routes });
11
+ for (const signal of ["SIGINT", "SIGTERM"]) {
12
+ process.on(signal, async (signal) => fastify
13
+ .close()
14
+ .then(() => {
15
+ logger.error(`Process interrupted and server closed. Received signal: ${signal}`);
16
+ process.exit(0);
17
+ })
18
+ .catch((error) => {
19
+ logger.error(`Server shutdown error: ${error}`);
20
+ process.exit(1);
21
+ }));
22
+ }
23
+ });
24
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEpE,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAEvD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE;IAC/B,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,CAAA;IACtB,MAAM,OAAO,GAAG,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAC1C,MAAM,MAAM,GAAG,aAAa,EAAE,CAAA;IAE9B,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;IAC7D,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAU,EAAE,CAAC;QAClD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAChC,OAAO;aACF,KAAK,EAAE;aACP,IAAI,CAAC,GAAG,EAAE;YACP,MAAM,CAAC,KAAK,CACR,2DAA2D,MAAM,EAAE,CACtE,CAAA;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,CAAC,KAAK,CAAC,0BAA0B,KAAK,EAAE,CAAC,CAAA;YAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC,CAAC,CACT,CAAA;IACL,CAAC;AACL,CAAC,CAAC,CAAA"}
@@ -0,0 +1,46 @@
1
+ import type { Logger } from "@logtape/logtape";
2
+ import type { FastifyPluginAsync, FastifyPluginCallback, FastifyPluginOptions, FastifyServerOptions, RouteOptions } from "fastify";
3
+ /**
4
+ * A plugin entry combining a Fastify plugin function with its options,
5
+ * stored in the plugins `Map` passed to {@link launcher}.
6
+ */
7
+ export type FSTPlugin = {
8
+ /** The Fastify plugin function to register. */
9
+ plugin: FastifyPluginCallback<any> | FastifyPluginAsync<any>;
10
+ /** Optional options forwarded to the plugin on registration. */
11
+ opts?: FastifyPluginOptions;
12
+ };
13
+ /**
14
+ * Application locals decorated onto the Fastify instance and available
15
+ * throughout the request lifecycle.
16
+ */
17
+ export type LauncherLocals = {
18
+ /** Package metadata (e.g. contents of `package.json`). */
19
+ pkg?: object;
20
+ /** Hostname the server will bind to. */
21
+ host?: string;
22
+ /** Port the server will listen on. */
23
+ port?: number;
24
+ /** Any additional application-specific locals. */
25
+ [key: string]: unknown;
26
+ };
27
+ /**
28
+ * Options passed to the {@link launcher} function.
29
+ */
30
+ export type LauncherOptions = {
31
+ /** Logger instance used for error and info output. */
32
+ logger: Logger;
33
+ /** Application locals decorated onto the Fastify instance. */
34
+ locals: LauncherLocals;
35
+ /** Map of named plugins to register. */
36
+ plugins: Map<string, FSTPlugin>;
37
+ /** Map of named routes to register. */
38
+ routes: Map<string, RouteOptions>;
39
+ /** Map of named decorators to add to the Fastify instance. */
40
+ decorators?: Map<string, unknown>;
41
+ /** Optional Fastify server options (merged over {@link defaultFastifyOptions}). */
42
+ opts?: FastifyServerOptions;
43
+ /** Optional callback invoked once the server is listening. */
44
+ done?: () => void;
45
+ };
46
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EACR,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACf,MAAM,SAAS,CAAA;AAEhB;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACpB,+CAA+C;IAE/C,MAAM,EAAE,qBAAqB,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA;IAC5D,gEAAgE;IAChE,IAAI,CAAC,EAAE,oBAAoB,CAAA;CAC9B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IACzB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kDAAkD;IAClD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACzB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAA;IACd,8DAA8D;IAC9D,MAAM,EAAE,cAAc,CAAA;IACtB,wCAAwC;IACxC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC/B,uCAAuC;IACvC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACjC,8DAA8D;IAC9D,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,mFAAmF;IACnF,IAAI,CAAC,EAAE,oBAAoB,CAAA;IAC3B,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@darthcav/ts-http-server",
3
+ "description": "A TypeScript HTTP server for Node.js >= 25",
4
+ "version": "0.0.1",
5
+ "author": {
6
+ "name": "darthcav"
7
+ },
8
+ "license": "Apache-2.0",
9
+ "type": "module",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "package.json",
21
+ "README.md",
22
+ "LICENSE",
23
+ "src/**/*.ts",
24
+ "src/**/*.tsx",
25
+ "dist/**/*.js",
26
+ "dist/**/*.js.map",
27
+ "dist/**/*.d.ts",
28
+ "dist/**/*.d.ts.map"
29
+ ],
30
+ "dependencies": {
31
+ "@darthcav/ts-utils": "0.8.0",
32
+ "@fastify/accepts": "5.0.4",
33
+ "@fastify/compress": "8.3.1",
34
+ "@fastify/cors": "11.2.0",
35
+ "@fastify/etag": "6.1.0",
36
+ "@fastify/helmet": "13.0.2",
37
+ "@fastify/static": "9.0.0",
38
+ "@fastify/view": "11.1.1",
39
+ "@hapi/boom": "10.0.1",
40
+ "@logtape/fastify": "2.0.4",
41
+ "@logtape/logtape": "2.0.4",
42
+ "ejs": "5.0.1",
43
+ "fastify": "5.8.2"
44
+ },
45
+ "devDependencies": {
46
+ "@biomejs/biome": "2.4.6",
47
+ "@types/ejs": "3.1.5",
48
+ "@types/node": "25.4.0",
49
+ "asserttt": "1.0.1",
50
+ "shx": "0.4.0",
51
+ "typedoc": "0.28.17"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git@github.com:darthcav/ts-http-server.git"
56
+ },
57
+ "engines": {
58
+ "node": ">=25"
59
+ },
60
+ "scripts": {
61
+ "\n===== Build =====": "",
62
+ "clean": "shx rm -rf dist/*",
63
+ "build": "npm run clean && tsc",
64
+ "prepare": "npm run build",
65
+ "\n===== Typecheck =====": "",
66
+ "typecheck": "tsc --noEmit",
67
+ "\n===== Test =====": "",
68
+ "test": "node --env-file=.env.local --test --test-reporter=spec 'src/**/*.test.ts'",
69
+ "test:coverage": "node --env-file=.env.local --experimental-test-coverage --test 'src/**/*.test.ts'",
70
+ "\n===== Linter =====": "",
71
+ "lint": "biome check .",
72
+ "lint:fix": "biome check --write .",
73
+ "\n===== TypeDoc =====": "",
74
+ "doc": "shx rm -rf public/* && typedoc --tsconfig tsconfig.json",
75
+ "\n===== Start =====": "",
76
+ "start": "node --env-file=.env.local src/start.ts"
77
+ }
78
+ }