create-forkly 0.6.2 → 0.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-forkly",
3
- "version": "0.6.2",
3
+ "version": "0.8.0",
4
4
  "description": "CLI to scaffold a new Forkly project",
5
5
  "type": "module",
6
6
  "bin": {
package/template/app.ts CHANGED
@@ -7,6 +7,13 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
7
7
 
8
8
  const app = new Forkly(loadConfig(undefined, resolve(__dirname, 'config')));
9
9
 
10
+ // 注册初始化回调 — 每个 Worker 进程启动时各执行一次(连接数据库、预热缓存等)
11
+ app.onInit(async () => {
12
+ // await connectDB();
13
+ // await preloadCache();
14
+ console.log('[INIT] Worker 进程就绪');
15
+ });
16
+
10
17
  // 注册全局日志回调
11
18
  app.onLog((level, message) => {
12
19
  console.log(`[${level.toUpperCase()}] ${message}`);
@@ -6,7 +6,6 @@ const Base = setRouter({
6
6
  });
7
7
 
8
8
  export class HelloRouter extends Base {
9
- static channel = 'async' as const;
10
9
 
11
10
  async get() {
12
11
  const name = this.request.query.name ?? 'World';
@@ -2,12 +2,11 @@
2
2
  import { Router } from 'forkly';
3
3
 
4
4
  export class IndexRouter extends Router {
5
- static channel = 'async' as const;
6
5
 
7
6
  async get() {
8
7
  return {
9
8
  message: 'Welcome to Forkly!',
10
- version: '0.5.0',
9
+ version: '0.8.0',
11
10
  timestamp: Date.now(),
12
11
  };
13
12
  }
@@ -8,7 +8,6 @@ const users: Record<string, { name: string; email: string }> = {
8
8
  };
9
9
 
10
10
  export class UserRouter extends Router {
11
- static channel = 'async' as const;
12
11
 
13
12
  async get() {
14
13
  const id = this.request.params.id;