@harpy-js/core 0.5.3 → 0.5.4

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.
@@ -2,6 +2,7 @@ import type { NestFastifyApplication } from "@nestjs/platform-fastify";
2
2
  export interface HarpyAppOptions {
3
3
  layout?: any;
4
4
  distDir?: string;
5
+ publicDir?: string;
5
6
  }
6
7
  export declare function configureHarpyApp(app: NestFastifyApplication, opts?: HarpyAppOptions): Promise<void>;
7
8
  export declare function setupHarpyApp(app: NestFastifyApplication, opts?: HarpyAppOptions): Promise<void>;
@@ -52,7 +52,7 @@ catch (e) {
52
52
  }
53
53
  const jsx_engine_1 = require("./jsx.engine");
54
54
  async function configureHarpyApp(app, opts = {}) {
55
- const { layout, distDir = "dist" } = opts;
55
+ const { layout, distDir = "dist", publicDir } = opts;
56
56
  if (layout) {
57
57
  (0, jsx_engine_1.withJsxEngine)(app, layout);
58
58
  }
@@ -69,6 +69,13 @@ async function configureHarpyApp(app, opts = {}) {
69
69
  prefix: "/",
70
70
  decorateReply: false,
71
71
  });
72
+ if (publicDir) {
73
+ await fastify.register(fastifyStatic, {
74
+ root: path.join(process.cwd(), publicDir),
75
+ prefix: "/",
76
+ decorateReply: false,
77
+ });
78
+ }
72
79
  }
73
80
  else {
74
81
  console.warn("[harpy-core] optional dependency `@fastify/static` is not installed; static `dist` handler not registered.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harpy-js/core",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Harpy - A powerful NestJS + React/JSX SSR framework with automatic hydration and i18n support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,6 +28,8 @@ export interface HarpyAppOptions {
28
28
  layout?: any;
29
29
  /** Folder containing built server assets (chunks) — defaults to `dist` */
30
30
  distDir?: string;
31
+ /** Optional folder containing public assets (favicon, manifest, etc.) */
32
+ publicDir?: string;
31
33
  }
32
34
 
33
35
  /**
@@ -43,7 +45,7 @@ export async function configureHarpyApp(
43
45
  app: NestFastifyApplication,
44
46
  opts: HarpyAppOptions = {},
45
47
  ) {
46
- const { layout, distDir = "dist" } = opts;
48
+ const { layout, distDir = "dist", publicDir } = opts;
47
49
 
48
50
  if (layout) {
49
51
  withJsxEngine(app, layout);
@@ -79,6 +81,16 @@ export async function configureHarpyApp(
79
81
  prefix: "/",
80
82
  decorateReply: false,
81
83
  });
84
+
85
+ // If publicDir is provided, register it as well for public assets
86
+ if (publicDir) {
87
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
88
+ await fastify.register(fastifyStatic, {
89
+ root: path.join(process.cwd(), publicDir),
90
+ prefix: "/",
91
+ decorateReply: false,
92
+ });
93
+ }
82
94
  } else {
83
95
  // If the static plugin is not available, emit a warning and continue.
84
96
  // Consumers who need hydration chunk serving in production should add