chore: import upstream snapshot with attribution
Lint and Format Check / lint-and-format (push) Failing after 0s
Check Migrations / Check for duplicate migration numbers (push) Failing after 1s
CI Pre-merge Check / CI Pre-merge Check (push) Failing after 2m17s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:23:40 +08:00
commit 3a28426bf4
1399 changed files with 257375 additions and 0 deletions
+91
View File
@@ -0,0 +1,91 @@
---
title: "Edge Functions"
sidebarTitle: "Overview"
description: "Deno-powered serverless TypeScript with first-class schedules."
---
Use InsForge edge functions to run TypeScript on [Deno](https://deno.com), deployed close to your users for low latency. Functions can be invoked on-demand from any client, chained from database triggers, or scheduled to run on a cron expression. The runtime ships standard fetch, streaming responses, and ESM imports out of the box.
<Note>
**Need a process that stays up?** Use [Compute](/core-concepts/compute/overview) for queue workers, AI inference loops, and anything stateful. Edge Functions are for request/response and short-lived jobs.
</Note>
```mermaid
graph TB
HTTP[HTTP Request] --> Fn[Edge Function on Deno]
Schedule[Cron Schedule] --> Fn
Trigger[Database Trigger] --> Fn
Fn --> SDK[InsForge SDK]
SDK --> DB[(Database)]
SDK --> Storage[Storage]
SDK --> Gateway[Model Gateway]
style HTTP fill:#1e293b,stroke:#475569,color:#e2e8f0
style Schedule fill:#1e293b,stroke:#475569,color:#e2e8f0
style Trigger fill:#4c1d95,stroke:#8b5cf6,color:#ede9fe
style Fn fill:#c2410c,stroke:#fb923c,color:#fed7aa
style SDK fill:#1e40af,stroke:#3b82f6,color:#dbeafe
style DB fill:#0e7490,stroke:#06b6d4,color:#cffafe
style Storage fill:#166534,stroke:#22c55e,color:#dcfce7
style Gateway fill:#166534,stroke:#22c55e,color:#dcfce7
```
## Features
### HTTP triggers
Every function is reachable at `https://<project>.insforge.dev/functions/<name>`. Standard fetch in, standard `Response` out. Streaming, JSON, redirects, and websockets all work.
### Schedules
Attach a cron expression to a function and InsForge invokes it on time, with retry on failure. See [Schedules](/core-concepts/functions/schedules) for the cron syntax and execution model.
### Database triggers
Wire a function to fire on `INSERT`, `UPDATE`, or `DELETE` against a table. The function receives the row payload and runs with a service-role JWT so it can perform privileged follow-up writes.
### Secrets and environment variables
Set env vars and secrets per function. The dashboard, CLI, and MCP all read and write the same store; secrets never round-trip through your repo.
### Logs
Structured logs are captured per invocation, queryable by status, duration, and function name. The InsForge MCP `get-function-logs` tool lets your agent diagnose failures without leaving the editor.
### Deno standard library
Use the [Deno standard library](https://jsr.io/@std) and any ESM module from `jsr.io`, `esm.sh`, or `npm:` specifiers. You don't run a bundler, and there's no `node_modules` directory to ship.
## Concepts
<CardGroup cols={2}>
<Card title="Schedules" icon="clock" href="/core-concepts/functions/schedules">
Run a function on a cron expression instead of in response to a request.
</Card>
</CardGroup>
## Build with it
<CardGroup cols={2}>
<Card title="TypeScript SDK" icon="js" href="/sdks/typescript/functions">
Invoke and stream functions from Node, browser, and edge.
</Card>
<Card title="Swift SDK" icon="swift" href="/sdks/swift/functions">
Invoke functions from iOS and macOS apps.
</Card>
<Card title="Kotlin SDK" icon="android" href="/sdks/kotlin/functions">
Invoke functions from Android and JVM apps.
</Card>
<Card title="REST API" icon="code" href="/sdks/rest/functions">
Plain HTTP function endpoints, callable from any language.
</Card>
</CardGroup>
## Next steps
- Set up the [CLI](/quickstart) to link your project (the recommended path).
- Browse the [TypeScript SDK reference](/sdks/typescript/functions) for invocation patterns.
@@ -0,0 +1,43 @@
---
title: "Schedules: cron-triggered functions"
description: "Run a function on a cron schedule using pg_cron"
---
Schedules invoke functions on a recurring cron expression. [pg_cron](https://github.com/citusdata/pg_cron) fires an HTTP request to the function URL at each tick and logs the result.
## Concepts
A schedule is a cron expression, a target URL, and headers. On creation, `${{secrets.KEY}}` placeholders in headers are resolved and encrypted with `pgcrypto`. At each tick, `execute_job()` decrypts headers, calls the function, and writes status and duration to `schedules.job_logs`.
## Usage
Standard 5-field cron (no seconds). Reference secrets in headers instead of hardcoding keys.
```text
*/5 * * * * every 5 minutes
0 * * * * every hour
0 0 * * * daily at midnight
0 9 * * 1 every Monday at 9am
0 0 1 * * first of every month
```
Create via dashboard or SQL:
```sql
select schedules.create_job(
name => 'daily-cleanup',
schedule => '0 0 * * *',
url => 'https://myapp.functions.insforge.app/cleanup',
headers => jsonb_build_object('Authorization', 'Bearer ${{secrets.CRON_TOKEN}}')
);
```
## Limits
Minimum interval is 1 minute (pg_cron). Failed runs are logged but not retried, so the function must be idempotent. Deleting a referenced secret breaks every job using it until you update or disable the schedule.
## More resources
- [pg_cron docs](https://github.com/citusdata/pg_cron) for cron syntax.
- [Functions overview](/core-concepts/functions/overview) for the runtime.
- [crontab.guru](https://crontab.guru) to check an expression.