clawfire 0.5.0 → 0.6.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/README.md +10 -10
- package/dist/cli.js +76 -16
- package/dist/codegen.cjs.map +1 -1
- package/dist/codegen.d.cts +1 -1
- package/dist/codegen.d.ts +1 -1
- package/dist/codegen.js.map +1 -1
- package/dist/{dev-server-5ATZVQJT.js → dev-server-GD445Q6F.js} +247 -6
- package/dist/dev.cjs +247 -6
- package/dist/dev.cjs.map +1 -1
- package/dist/dev.js +247 -6
- package/dist/dev.js.map +1 -1
- package/dist/{discover-DYNqz_ym.d.cts → discover-8p9Mujyt.d.cts} +3 -3
- package/dist/{discover-DYNqz_ym.d.ts → discover-8p9Mujyt.d.ts} +3 -3
- package/dist/functions.cjs.map +1 -1
- package/dist/functions.d.cts +1 -1
- package/dist/functions.d.ts +1 -1
- package/dist/functions.js.map +1 -1
- package/package.json +1 -1
- package/templates/CLAUDE.md +22 -19
- package/templates/functions/index.ts +3 -3
- package/templates/starter/.claude/skills/clawfire-api/SKILL.md +8 -8
- package/templates/starter/.claude/skills/clawfire-diagnose/SKILL.md +6 -6
- package/templates/starter/.claude/skills/clawfire-model/SKILL.md +2 -2
- package/templates/starter/CLAUDE.md +33 -31
- package/templates/starter/app/pages/index.html +7 -6
- package/templates/starter/functions/index.ts +52 -0
- package/templates/starter/functions/package.json +22 -0
- package/templates/starter/functions/tsconfig.json +18 -0
- package/templates/starter/package.json +4 -2
- package/templates/starter/tsconfig.json +1 -1
- /package/templates/{app → functions}/routes/auth/login.ts +0 -0
- /package/templates/{app → functions}/routes/health.ts +0 -0
- /package/templates/{app → functions}/schemas/user.ts +0 -0
- /package/templates/starter/{app → functions}/routes/health.ts +0 -0
- /package/templates/starter/{app → functions}/routes/todos/create.ts +0 -0
- /package/templates/starter/{app → functions}/routes/todos/delete.ts +0 -0
- /package/templates/starter/{app → functions}/routes/todos/list.ts +0 -0
- /package/templates/starter/{app → functions}/routes/todos/update.ts +0 -0
- /package/templates/starter/{app → functions}/schemas/todo.ts +0 -0
- /package/templates/starter/{app → functions}/store.ts +0 -0
|
@@ -26,36 +26,38 @@ This is a **Clawfire** project — an AI-First Firebase app framework.
|
|
|
26
26
|
## Project Structure
|
|
27
27
|
|
|
28
28
|
```
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_404.html ← 404 에러 페이지
|
|
34
|
-
index.html ← 홈 페이지 (/)
|
|
35
|
-
about.html ← /about 페이지
|
|
36
|
-
todos/
|
|
37
|
-
index.html ← /todos 페이지
|
|
38
|
-
components/ ← 재사용 HTML 컴포넌트
|
|
39
|
-
nav.html ← <c-nav /> 네비게이션
|
|
40
|
-
footer.html ← <c-footer /> 푸터
|
|
41
|
-
routes/ ← API 라우트 핸들러 (파일 기반 라우팅)
|
|
42
|
-
health.ts ← 서버 상태 확인
|
|
43
|
-
todos/ ← Todo CRUD
|
|
29
|
+
functions/ ← Backend (Firebase Functions, 독립 빌드 단위)
|
|
30
|
+
routes/ ← API 라우트 핸들러 (파일 기반 라우팅)
|
|
31
|
+
health.ts ← 서버 상태 확인
|
|
32
|
+
todos/ ← Todo CRUD
|
|
44
33
|
list.ts
|
|
45
34
|
create.ts
|
|
46
35
|
update.ts
|
|
47
36
|
delete.ts
|
|
48
|
-
schemas/
|
|
37
|
+
schemas/ ← Firestore 모델 정의
|
|
49
38
|
todo.ts
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
functions
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
store.ts ← 인메모리 데이터 저장소 (Firebase 없이 동작)
|
|
40
|
+
index.ts ← Firebase Functions 진입점 (배포용)
|
|
41
|
+
package.json ← Backend 의존성 (firebase-admin, firebase-functions)
|
|
42
|
+
tsconfig.json ← Backend TypeScript 설정
|
|
43
|
+
app/ ← Frontend only
|
|
44
|
+
pages/ ← 파일 기반 페이지 라우팅 (프론트엔드)
|
|
45
|
+
_layout.html ← 루트 레이아웃 (모든 페이지 래핑)
|
|
46
|
+
_404.html ← 404 에러 페이지
|
|
47
|
+
index.html ← 홈 페이지 (/)
|
|
48
|
+
about.html ← /about 페이지
|
|
49
|
+
todos/
|
|
50
|
+
index.html ← /todos 페이지
|
|
51
|
+
components/ ← 재사용 HTML 컴포넌트
|
|
52
|
+
nav.html ← <c-nav /> 네비게이션
|
|
53
|
+
footer.html ← <c-footer /> 푸터
|
|
54
|
+
public/ ← 정적 파일 (CSS, JS, 이미지, 폰트)
|
|
55
|
+
generated/ ← 자동 생성 파일 (DO NOT EDIT)
|
|
56
|
+
dev.ts ← Dev 서버 진입점
|
|
57
|
+
clawfire.config.ts ← Clawfire 설정
|
|
58
|
+
firebase.json ← Firebase 설정
|
|
59
|
+
firestore.rules ← Firestore 보안 규칙
|
|
60
|
+
firestore.indexes.json ← Firestore 인덱스
|
|
59
61
|
```
|
|
60
62
|
|
|
61
63
|
---
|
|
@@ -142,9 +144,9 @@ export const Todo = defineModel({
|
|
|
142
144
|
파일 경로 = API 경로:
|
|
143
145
|
|
|
144
146
|
```
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
functions/routes/health.ts → POST /api/health
|
|
148
|
+
functions/routes/todos/list.ts → POST /api/todos/list
|
|
149
|
+
functions/routes/products/[id]/get.ts → POST /api/products/:id/get
|
|
148
150
|
```
|
|
149
151
|
|
|
150
152
|
---
|
|
@@ -187,16 +189,16 @@ throw Errors.conflict("Already exists"); // 409
|
|
|
187
189
|
|
|
188
190
|
### Step 1: Store 추가 (인메모리 모드)
|
|
189
191
|
|
|
190
|
-
`
|
|
192
|
+
`functions/store.ts`에 새 Map + CRUD 메서드 추가.
|
|
191
193
|
|
|
192
194
|
### Step 2: Schema 생성
|
|
193
195
|
|
|
194
|
-
`
|
|
196
|
+
`functions/schemas/product.ts` 생성 → `defineModel(...)`.
|
|
195
197
|
|
|
196
198
|
### Step 3: Routes 생성
|
|
197
199
|
|
|
198
200
|
```
|
|
199
|
-
|
|
201
|
+
functions/routes/products/
|
|
200
202
|
list.ts ← 목록 조회
|
|
201
203
|
create.ts ← 생성
|
|
202
204
|
update.ts ← 수정
|
|
@@ -61,10 +61,11 @@
|
|
|
61
61
|
<div class="mt-2"><span class="text-brand-400">app/components/</span> <span class="text-zinc-600 ml-2">← Reusable HTML components</span></div>
|
|
62
62
|
<div class="pl-4">nav.html <span class="text-zinc-600 ml-2">← Used as <code class="text-zinc-500"><c-nav /></code></span></div>
|
|
63
63
|
<div class="pl-4">footer.html <span class="text-zinc-600 ml-2">← Used as <code class="text-zinc-500"><c-footer /></code></span></div>
|
|
64
|
-
<div class="mt-2"><span class="text-brand-400">
|
|
65
|
-
<div class="pl-4">health.ts <span class="text-zinc-600 ml-2">← <code class="text-zinc-500">POST /api/health</code></span></div>
|
|
66
|
-
<div class="pl-4">todos/*.ts <span class="text-zinc-600 ml-2">← Todo CRUD APIs</span></div>
|
|
67
|
-
<div class="
|
|
64
|
+
<div class="mt-2"><span class="text-brand-400">functions/</span> <span class="text-zinc-600 ml-2">← Backend (Firebase Functions)</span></div>
|
|
65
|
+
<div class="pl-4">routes/health.ts <span class="text-zinc-600 ml-2">← <code class="text-zinc-500">POST /api/health</code></span></div>
|
|
66
|
+
<div class="pl-4">routes/todos/*.ts <span class="text-zinc-600 ml-2">← Todo CRUD APIs</span></div>
|
|
67
|
+
<div class="pl-4">schemas/todo.ts <span class="text-zinc-600 ml-2">← Firestore model definitions</span></div>
|
|
68
|
+
<div class="pl-4">index.ts <span class="text-zinc-600 ml-2">← Cloud Function entry point</span></div>
|
|
68
69
|
<div class="mt-2"><span class="text-brand-400">public/</span> <span class="text-zinc-600 ml-2">← Static assets (CSS, images, fonts)</span></div>
|
|
69
70
|
</div>
|
|
70
71
|
</div>
|
|
@@ -114,11 +115,11 @@
|
|
|
114
115
|
<div class="bg-zinc-900 border border-zinc-800 rounded-xl p-6 mb-8">
|
|
115
116
|
<h2 class="text-lg font-semibold mb-4">How APIs Work</h2>
|
|
116
117
|
<p class="text-zinc-500 text-sm mb-4">
|
|
117
|
-
Every file in <code class="text-brand-400 bg-zinc-800 px-1.5 py-0.5 rounded text-xs">
|
|
118
|
+
Every file in <code class="text-brand-400 bg-zinc-800 px-1.5 py-0.5 rounded text-xs">functions/routes/</code> becomes a POST endpoint.
|
|
118
119
|
Define input/output with Zod schemas, and get type safety + auto-generated docs.
|
|
119
120
|
</p>
|
|
120
121
|
<div class="bg-zinc-950 rounded-lg p-4 font-mono text-xs text-zinc-400 overflow-x-auto mb-4">
|
|
121
|
-
<div class="text-zinc-600">//
|
|
122
|
+
<div class="text-zinc-600">// functions/routes/todos/create.ts</div>
|
|
122
123
|
<div><span class="text-purple-400">import</span> { defineAPI, z } <span class="text-purple-400">from</span> <span class="text-green-400">"clawfire"</span>;</div>
|
|
123
124
|
<div class="mt-2"><span class="text-purple-400">export default</span> <span class="text-blue-400">defineAPI</span>({</div>
|
|
124
125
|
<div class="pl-4">input: z.<span class="text-blue-400">object</span>({ title: z.<span class="text-blue-400">string</span>() }),</div>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clawfire Firebase Functions Entry Point
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for your Firebase Functions.
|
|
5
|
+
* Routes are automatically registered from functions/routes/.
|
|
6
|
+
*/
|
|
7
|
+
import * as admin from "firebase-admin";
|
|
8
|
+
import * as functions from "firebase-functions";
|
|
9
|
+
import {
|
|
10
|
+
createRouter,
|
|
11
|
+
createAdminDB,
|
|
12
|
+
createSecurityMiddleware,
|
|
13
|
+
} from "clawfire/functions";
|
|
14
|
+
|
|
15
|
+
// Initialize Firebase Admin
|
|
16
|
+
admin.initializeApp();
|
|
17
|
+
|
|
18
|
+
// Create database wrapper
|
|
19
|
+
export const db = createAdminDB(admin.firestore());
|
|
20
|
+
|
|
21
|
+
// Create router with security middleware
|
|
22
|
+
const router = createRouter({
|
|
23
|
+
auth: admin.auth(),
|
|
24
|
+
cors: [], // Add your allowed origins here
|
|
25
|
+
middleware: createSecurityMiddleware({
|
|
26
|
+
logRequests: true,
|
|
27
|
+
sanitize: true,
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// ── Register Routes ─────────────────────────────────────────────
|
|
32
|
+
// Routes are registered here. Use /clawfire-api skill to auto-manage this.
|
|
33
|
+
|
|
34
|
+
import healthRoute from "./routes/health.js";
|
|
35
|
+
router.register("/health", healthRoute);
|
|
36
|
+
|
|
37
|
+
import todosListRoute from "./routes/todos/list.js";
|
|
38
|
+
router.register("/todos/list", todosListRoute);
|
|
39
|
+
|
|
40
|
+
import todosCreateRoute from "./routes/todos/create.js";
|
|
41
|
+
router.register("/todos/create", todosCreateRoute);
|
|
42
|
+
|
|
43
|
+
import todosUpdateRoute from "./routes/todos/update.js";
|
|
44
|
+
router.register("/todos/update", todosUpdateRoute);
|
|
45
|
+
|
|
46
|
+
import todosDeleteRoute from "./routes/todos/delete.js";
|
|
47
|
+
router.register("/todos/delete", todosDeleteRoute);
|
|
48
|
+
|
|
49
|
+
// ── Export Cloud Function ────────────────────────────────────────
|
|
50
|
+
export const api = functions.https.onRequest((req, res) => {
|
|
51
|
+
router.handleRequest(req as any, res as any);
|
|
52
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "functions",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsc",
|
|
7
|
+
"build:watch": "tsc --watch"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": "20"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"clawfire": "latest",
|
|
15
|
+
"firebase-admin": "^13.0.0",
|
|
16
|
+
"firebase-functions": "^6.0.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5.5.0",
|
|
20
|
+
"@types/node": "^20.0.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": ".",
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"sourceMap": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["**/*.ts"],
|
|
17
|
+
"exclude": ["node_modules", "dist"]
|
|
18
|
+
}
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "npx tsx dev.ts",
|
|
8
|
-
"build": "
|
|
9
|
-
"
|
|
8
|
+
"build": "cd functions && npm run build",
|
|
9
|
+
"build:check": "tsc --noEmit",
|
|
10
|
+
"deploy": "cd functions && npm run build && cd .. && firebase deploy",
|
|
11
|
+
"postinstall": "cd functions && npm install"
|
|
10
12
|
},
|
|
11
13
|
"dependencies": {
|
|
12
14
|
"clawfire": "latest"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|