@kanjijs/cli 0.2.0-beta.51 → 0.2.0-beta.53

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanjijs/cli",
3
- "version": "0.2.0-beta.51",
3
+ "version": "0.2.0-beta.53",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "kanji": "./dist/index.js"
@@ -21,7 +21,7 @@
21
21
  "fs-extra": "^11.3.3",
22
22
  "picocolors": "^1.1.1",
23
23
  "openapi-typescript-codegen": "^0.25.0",
24
- "@kanjijs/openapi": "^0.2.0-beta.51"
24
+ "@kanjijs/openapi": "^0.2.0-beta.53"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/fs-extra": "^11.0.4"
@@ -7,18 +7,18 @@
7
7
  "start": "bun run src/main.ts"
8
8
  },
9
9
  "dependencies": {
10
- "@kanjijs/core": "^0.2.0-beta.50",
11
- "@kanjijs/platform-bun": "^0.2.0-beta.50",
12
- "@kanjijs/platform-hono": "^0.2.0-beta.50",
13
- "@kanjijs/auth": "^0.2.0-beta.50",
14
- "@kanjijs/logger": "^0.2.0-beta.50",
15
- "@kanjijs/throttler": "^0.2.0-beta.50",
10
+ "@kanjijs/core": "^0.2.0-beta.53",
11
+ "@kanjijs/platform-bun": "^0.2.0-beta.53",
12
+ "@kanjijs/platform-hono": "^0.2.0-beta.53",
13
+ "@kanjijs/auth": "^0.2.0-beta.53",
14
+ "@kanjijs/logger": "^0.2.0-beta.53",
15
+ "@kanjijs/throttler": "^0.2.0-beta.53",
16
16
  "hono": "^4.0.0",
17
17
  "reflect-metadata": "^0.2.0",
18
18
  "zod": "^3.0.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/bun": "latest",
22
- "@kanjijs/testing": "^0.2.0-beta.50"
22
+ "@kanjijs/testing": "^0.2.0-beta.53"
23
23
  }
24
24
  }
@@ -2,16 +2,22 @@ import "reflect-metadata";
2
2
  import { KanjijsAdapter } from "@kanjijs/platform-hono";
3
3
  import { AppModule } from "./app.module";
4
4
 
5
- const { app } = KanjijsAdapter.create(AppModule, {
6
- cors: true, // Default CORS
7
- logger: true, // Default Logger
8
- // globalPrefix: "/api"
9
- });
10
- const port = 3000;
5
+ // Lazy initialization to prevent race conditions during hot-reload
6
+ let app: ReturnType<typeof KanjijsAdapter.create>["app"] | null = null;
11
7
 
12
- console.log(`Server running on port ${port}`);
8
+ function getApp() {
9
+ if (!app) {
10
+ const result = KanjijsAdapter.create(AppModule, {
11
+ cors: true,
12
+ logger: true,
13
+ });
14
+ app = result.app;
15
+ console.log("Server configured and ready");
16
+ }
17
+ return app;
18
+ }
13
19
 
14
20
  export default {
15
- port,
16
- fetch: app.fetch,
21
+ port: Number(process.env.PORT) || 3000,
22
+ fetch: (req: Request) => getApp().fetch(req),
17
23
  };