rsf-zero 0.3.4 → 0.3.6

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.
package/README.md CHANGED
@@ -40,9 +40,6 @@ See [/example/src/App.tsx](https://github.com/IgorNadj/rsf-zero/tree/main/exampl
40
40
  - [React Server Functions](https://react.dev/reference/rsc/server-functions)
41
41
  - Note: only the top-level `'use server'` is implemented by this framework.
42
42
 
43
- ## Configuring
44
- See [configuring](https://github.com/IgorNadj/rsf-zero/tree/main/docs/configuring.md)
45
-
46
43
  ## Motivation
47
44
 
48
45
  **RSF Zero** is designed to be a dead simple micro-framework.
@@ -51,4 +48,4 @@ Read the [blog post](https://igornadj.io/blog/2025-08-02-rsf-is-all-you-need/) f
51
48
 
52
49
  🕊 **Minimal**: Add whatever you want on top, nothing bundled that you don't use\
53
50
  🕊 **Simple**: Add `'use server'` to run something on the server, and you're done, nothing new to learn\
54
- 🕊️ **Done**: Instead, spend your spare time sipping a nice coffee or looking at a bird
51
+ 🕊️ **Done**: Instead, spend your spare time sipping a tea or looking at a nice bird
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AAGA,OAAO,eAAe,CAAC;AAMvB,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAGvD,eAAO,MAAM,GAAG,GAAU,SAAS,aAAa,kBAiC/C,CAAA"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AAGA,OAAO,eAAe,CAAC;AAMvB,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAIvD,eAAO,MAAM,GAAG,GAAU,SAAS,aAAa,kBAqC/C,CAAA"}
package/dist/cli/dev.js CHANGED
@@ -6,9 +6,12 @@ import { createActionRoute } from "./start/createActionRoute.js";
6
6
  import { debug } from "../utils/debug.js";
7
7
  import { customRoutesHook } from "../utils/customRoutesHook.js";
8
8
  import { onStartHook } from "../utils/onStartHook.js";
9
+ import { onBeforeStartHook } from "../utils/onBeforeStartHook.js";
9
10
  export const dev = async (options) => {
10
11
  const app = express();
11
12
  const port = 3000;
13
+ // onBeforeStart hook
14
+ await onBeforeStartHook(options, app);
12
15
  app.use(morgan("dev"));
13
16
  app.use(express.json());
14
17
  // Dev RSF handler
@@ -28,6 +31,7 @@ export const dev = async (options) => {
28
31
  // - transform any actions found for the frontend
29
32
  // - and inform the onActionFound callback above
30
33
  const vite = await startVite({ app, onActionFound });
34
+ // onStart hook
31
35
  await onStartHook(options, app);
32
36
  app.listen(port, () => {
33
37
  console.log(`Server is running at http://localhost:${port}`);
@@ -1 +1 @@
1
- {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":"AAIA,OAAO,eAAe,CAAC;AAGvB,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAMvD,eAAO,MAAM,KAAK,GAAU,SAAS,aAAa,kBAoCjD,CAAA"}
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":"AAIA,OAAO,eAAe,CAAC;AAGvB,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAMvD,eAAO,MAAM,KAAK,GAAU,SAAS,aAAa,kBAwCjD,CAAA"}
package/dist/cli/start.js CHANGED
@@ -13,10 +13,13 @@ import "dotenv/config";
13
13
  import { createActionRoute } from "./start/createActionRoute.js";
14
14
  import { debug } from "../utils/debug.js";
15
15
  import { customRoutesHook } from "../utils/customRoutesHook.js";
16
+ import { onBeforeStartHook } from "../utils/onBeforeStartHook.js";
16
17
  import { onStartHook } from "../utils/onStartHook.js";
17
18
  export const start = async (options) => {
18
19
  const app = express();
19
20
  const port = 3000;
21
+ // onBeforeStart hook
22
+ await onBeforeStartHook(options, app);
20
23
  app.use(morgan("dev"));
21
24
  app.use(express.json());
22
25
  // Server
@@ -40,6 +43,7 @@ export const start = async (options) => {
40
43
  res.sendFile(path.join(process.cwd(), 'dist/client/index.html'));
41
44
  }
42
45
  });
46
+ // onStart hook
43
47
  await onStartHook(options, app);
44
48
  app.listen(port, () => {
45
49
  console.log(`Server is running at http://localhost:${port}`);
@@ -4,5 +4,6 @@ export type RsfZeroConfig = {
4
4
  startStatic?: serveStatic.ServeStaticOptions;
5
5
  routes?: string[];
6
6
  onStart?: string;
7
+ onBeforeStart?: string;
7
8
  };
8
9
  //# sourceMappingURL=export-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"export-types.d.ts","sourceRoot":"","sources":["../../src/utils/export-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAA"}
1
+ {"version":3,"file":"export-types.d.ts","sourceRoot":"","sources":["../../src/utils/export-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { Express } from "express";
2
+ import { RsfZeroConfig } from "./export-types.js";
3
+ export declare const onBeforeStartHook: (options: RsfZeroConfig, app: Express) => Promise<void>;
4
+ //# sourceMappingURL=onBeforeStartHook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onBeforeStartHook.d.ts","sourceRoot":"","sources":["../../src/utils/onBeforeStartHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAGhD,eAAO,MAAM,iBAAiB,GAAU,SAAS,aAAa,EAAE,KAAK,OAAO,kBA+B3E,CAAA"}
@@ -0,0 +1,35 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ import path from 'path';
10
+ import { debug } from "./debug.js";
11
+ export const onBeforeStartHook = async (options, app) => {
12
+ const { onBeforeStart } = options;
13
+ if (onBeforeStart) {
14
+ debug(`onBeforeStart config option found`);
15
+ if (typeof onBeforeStart !== 'string') {
16
+ throw new Error('Invalid onBeforeStart option. Must be a string.');
17
+ }
18
+ const absolutePath = path.isAbsolute(onBeforeStart)
19
+ ? onBeforeStart
20
+ : path.join(process.cwd(), onBeforeStart);
21
+ debug(`Loading onBeforeStart from: ${absolutePath}`);
22
+ const module = await import(__rewriteRelativeImportExtension(absolutePath));
23
+ const exportNames = Object.keys(module);
24
+ if (exportNames.length !== 1) {
25
+ throw new Error(`File ${absolutePath} must contain a single export.`);
26
+ }
27
+ const [firstExportName] = exportNames;
28
+ const firstExport = module[firstExportName];
29
+ if (!(typeof firstExport === 'function')) {
30
+ throw new Error(`File ${absolutePath} must export a function`);
31
+ }
32
+ firstExport(app);
33
+ debug(`onBeforeStart loaded successfully: ${absolutePath}`);
34
+ }
35
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A minimal micro-framework with React Server Functions support",
4
4
  "author": "Igor Nadj",
5
5
  "type": "module",
6
- "version": "0.3.4",
6
+ "version": "0.3.6",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/IgorNadj/rsf-zero.git",