flingit 0.0.2 → 0.0.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.
- package/README.md +8 -9
- package/dist/cli/commands/admin.d.ts +8 -0
- package/dist/cli/commands/admin.d.ts.map +1 -0
- package/dist/cli/commands/admin.js +231 -0
- package/dist/cli/commands/admin.js.map +1 -0
- package/dist/cli/commands/cron.d.ts +6 -0
- package/dist/cli/commands/cron.d.ts.map +1 -0
- package/dist/cli/commands/cron.js +197 -0
- package/dist/cli/commands/cron.js.map +1 -0
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +3 -1
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/commands/push.d.ts.map +1 -1
- package/dist/cli/commands/push.js +18 -4
- package/dist/cli/commands/push.js.map +1 -1
- package/dist/cli/deploy/assets.d.ts +8 -8
- package/dist/cli/deploy/assets.d.ts.map +1 -1
- package/dist/cli/deploy/assets.js +15 -15
- package/dist/cli/deploy/assets.js.map +1 -1
- package/dist/cli/deploy/bundler.d.ts +20 -3
- package/dist/cli/deploy/bundler.d.ts.map +1 -1
- package/dist/cli/deploy/bundler.js +89 -4
- package/dist/cli/deploy/bundler.js.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/worker-runtime/index.d.ts +32 -3
- package/dist/worker-runtime/index.d.ts.map +1 -1
- package/dist/worker-runtime/index.js +28 -2
- package/dist/worker-runtime/index.js.map +1 -1
- package/package.json +3 -3
- package/templates/default/CLAUDE.md +37 -3
- package/templates/default/skills/fling/SKILL.md +24 -2
|
@@ -4,12 +4,13 @@ You are working on a Fling project - a personal software platform for building a
|
|
|
4
4
|
|
|
5
5
|
## Core Concepts
|
|
6
6
|
|
|
7
|
-
Fling provides
|
|
7
|
+
Fling provides five primitives that work identically in local development and production:
|
|
8
8
|
|
|
9
9
|
1. **HTTP** - Expose endpoints via Hono
|
|
10
10
|
2. **Database** - SQLite locally, D1 in production
|
|
11
11
|
3. **Secrets** - Secure credential management
|
|
12
12
|
4. **Migrations** - Version your database schema
|
|
13
|
+
5. **Cron** - Scheduled tasks that run on a schedule
|
|
13
14
|
|
|
14
15
|
## Project Structure
|
|
15
16
|
|
|
@@ -52,6 +53,20 @@ await db.prepare("CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, name
|
|
|
52
53
|
|
|
53
54
|
// Secrets (throws if not set)
|
|
54
55
|
const token = secrets.get("API_TOKEN");
|
|
56
|
+
|
|
57
|
+
// Cron jobs - run on a schedule
|
|
58
|
+
import { cron } from "flingit";
|
|
59
|
+
|
|
60
|
+
cron("daily-cleanup", "0 3 * * *", async () => {
|
|
61
|
+
// Runs at 3 AM daily
|
|
62
|
+
await db.prepare("DELETE FROM old_logs WHERE created_at < ?").bind(Date.now() - 86400000).run();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
cron("hourly-stats", "0 * * * *", async () => {
|
|
66
|
+
// Runs every hour
|
|
67
|
+
const stats = await generateStats();
|
|
68
|
+
return { processed: stats.count }; // Optional return value stored in history
|
|
69
|
+
});
|
|
55
70
|
```
|
|
56
71
|
|
|
57
72
|
```typescript
|
|
@@ -88,6 +103,9 @@ npm exec fling logs # View local logs
|
|
|
88
103
|
npm exec fling push # Build and deploy to Cloudflare Workers
|
|
89
104
|
npm exec fling project slug # Show current project slug and URL
|
|
90
105
|
npm exec fling project slug:set <new-slug> # Change project slug (affects URL)
|
|
106
|
+
npm exec fling cron list # List registered cron jobs
|
|
107
|
+
npm exec fling cron history <name> # View invocation history
|
|
108
|
+
npm exec fling cron trigger <name> # Manually trigger a cron job
|
|
91
109
|
```
|
|
92
110
|
|
|
93
111
|
### Local vs Production (`--prod`)
|
|
@@ -106,6 +124,8 @@ npm exec fling -- --prod logs # Deployed logs
|
|
|
106
124
|
npm exec fling -- --prod db sql "SELECT 1" # Deployed D1
|
|
107
125
|
```
|
|
108
126
|
|
|
127
|
+
**Note:** Production logs have a delay of ~10 seconds or more before they appear.
|
|
128
|
+
|
|
109
129
|
## Development
|
|
110
130
|
|
|
111
131
|
Run `npm start` (or `fling dev`) to start development:
|
|
@@ -144,7 +164,7 @@ When the user's request is complete and working locally, deploy it:
|
|
|
144
164
|
|
|
145
165
|
2. **Memory limit (~128MB)** - Workers have limited memory. Cannot process large datasets in memory. Use streaming, pagination, or chunked processing for large data.
|
|
146
166
|
|
|
147
|
-
3. **Feature scope** - Fling supports frontend, backend, and
|
|
167
|
+
3. **Feature scope** - Fling supports frontend, backend, database, and cron jobs. Not yet supported: file/blob storage, websockets. If users need these, encourage feedback via `npm exec fling feedback`.
|
|
148
168
|
|
|
149
169
|
4. **Database operations cannot be at module top-level** - They must be inside route handlers or functions called by them.
|
|
150
170
|
|
|
@@ -154,6 +174,8 @@ When the user's request is complete and working locally, deploy it:
|
|
|
154
174
|
|
|
155
175
|
7. **Run commands yourself** - You have bash access. Don't ask the user to run `fling push`, `fling dev`, `npm start`, etc. Execute them directly.
|
|
156
176
|
|
|
177
|
+
8. **Reserved paths (`/__*`)** - Paths starting with `/__` are reserved for internal platform use (e.g., `/__cron` for cron jobs). Do not create routes with these prefixes.
|
|
178
|
+
|
|
157
179
|
**If the user's request might hit platform limitations, warn them early and suggest alternatives.**
|
|
158
180
|
|
|
159
181
|
See API.md for detailed API reference and EXAMPLES.md for common patterns.
|