packwise-skills 1.0.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/.cursorrules +23 -0
- package/CLAUDE.md +25 -0
- package/README.md +295 -0
- package/audit.md +224 -0
- package/bin/packwise.js +155 -0
- package/package.json +31 -0
- package/skill.md +719 -0
- package/sub-skills/ai/local-llm.md +183 -0
- package/sub-skills/ai/python-ml.md +164 -0
- package/sub-skills/backend/go-server.md +184 -0
- package/sub-skills/backend/java-spring.md +241 -0
- package/sub-skills/backend/node-server.md +164 -0
- package/sub-skills/backend/php-laravel.md +175 -0
- package/sub-skills/backend/python-server.md +164 -0
- package/sub-skills/backend/rust-backend.md +118 -0
- package/sub-skills/cli/python-cli.md +236 -0
- package/sub-skills/cli/sdk-library.md +497 -0
- package/sub-skills/cloud/ci-cd-pipelines.md +350 -0
- package/sub-skills/cloud/docker.md +191 -0
- package/sub-skills/cloud/kubernetes.md +277 -0
- package/sub-skills/cloud/payment-integration.md +307 -0
- package/sub-skills/cross-platform/multiplatform.md +252 -0
- package/sub-skills/desktop/electron.md +783 -0
- package/sub-skills/desktop/game-dev.md +443 -0
- package/sub-skills/desktop/native-app.md +123 -0
- package/sub-skills/desktop/scenarios.md +443 -0
- package/sub-skills/desktop/smart-platforms.md +324 -0
- package/sub-skills/desktop/tauri.md +428 -0
- package/sub-skills/desktop/vr-ar.md +252 -0
- package/sub-skills/desktop/web-to-desktop.md +153 -0
- package/sub-skills/embedded/car-infotainment.md +129 -0
- package/sub-skills/embedded/esp32.md +184 -0
- package/sub-skills/embedded/ros.md +150 -0
- package/sub-skills/embedded/stm32.md +160 -0
- package/sub-skills/mobile/android.md +322 -0
- package/sub-skills/mobile/capacitor.md +232 -0
- package/sub-skills/mobile/flutter-mobile.md +138 -0
- package/sub-skills/mobile/harmonyos.md +150 -0
- package/sub-skills/mobile/ios.md +245 -0
- package/sub-skills/mobile/react-native.md +443 -0
- package/sub-skills/mobile/wearables.md +230 -0
- package/sub-skills/plugins/browser-extension.md +308 -0
- package/sub-skills/plugins/jetbrains-plugin.md +226 -0
- package/sub-skills/plugins/vscode-extension.md +204 -0
- package/sub-skills/security/security-tools.md +174 -0
- package/sub-skills/web/monorepo.md +274 -0
- package/sub-skills/web/pwa.md +220 -0
- package/sub-skills/web/serverless-edge.md +295 -0
- package/sub-skills/web/spa.md +266 -0
- package/sub-skills/web/ssr.md +228 -0
- package/sub-skills/web/wasm.md +243 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Progressive Web App (PWA) Build Sub-Skill
|
|
2
|
+
|
|
3
|
+
Build installable web applications that work offline and feel like native apps.
|
|
4
|
+
|
|
5
|
+
**Current version**: PWA standards (2025-2026) — Service Workers, Web App Manifest, Web Push
|
|
6
|
+
|
|
7
|
+
## When to Use
|
|
8
|
+
|
|
9
|
+
- Need cross-platform app from single web codebase
|
|
10
|
+
- Offline support required
|
|
11
|
+
- Push notifications needed
|
|
12
|
+
- App-like experience without app store submission
|
|
13
|
+
- Budget-constrained projects (one codebase for all platforms)
|
|
14
|
+
|
|
15
|
+
## Key Features
|
|
16
|
+
|
|
17
|
+
| Feature | Browser Support | Notes |
|
|
18
|
+
|---------|---------------|-------|
|
|
19
|
+
| Service Worker | All modern browsers | Offline caching, background sync |
|
|
20
|
+
| Web App Manifest | All modern browsers | Home screen install, splash screen |
|
|
21
|
+
| Web Push | Chrome/Firefox/Edge/Safari 16.4+ | Push notifications on all platforms |
|
|
22
|
+
| Background Sync | Chrome/Edge | Sync data when connection restored |
|
|
23
|
+
| Periodic Background Sync | Chrome/Edge only | Fetch updates in background |
|
|
24
|
+
| File System Access | Chrome/Edge | Read/write local files |
|
|
25
|
+
| Web Share API | Chrome/Edge/Safari | Native share dialog |
|
|
26
|
+
|
|
27
|
+
## PWA Essentials
|
|
28
|
+
|
|
29
|
+
### 1. Web App Manifest
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"name": "My PWA App",
|
|
34
|
+
"short_name": "MyApp",
|
|
35
|
+
"description": "My Progressive Web App",
|
|
36
|
+
"start_url": "/",
|
|
37
|
+
"display": "standalone",
|
|
38
|
+
"background_color": "#ffffff",
|
|
39
|
+
"theme_color": "#000000",
|
|
40
|
+
"orientation": "portrait",
|
|
41
|
+
"icons": [
|
|
42
|
+
{ "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
|
|
43
|
+
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png" },
|
|
44
|
+
{ "src": "/icons/icon-512-maskable.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
|
|
45
|
+
],
|
|
46
|
+
"screenshots": [
|
|
47
|
+
{ "src": "/screenshots/desktop.png", "sizes": "1280x720", "form_factor": "wide" },
|
|
48
|
+
{ "src": "/screenshots/mobile.png", "sizes": "390x844", "form_factor": "narrow" }
|
|
49
|
+
],
|
|
50
|
+
"categories": ["productivity"],
|
|
51
|
+
"shortcuts": [
|
|
52
|
+
{ "name": "Settings", "url": "/settings", "icons": [{ "src": "/icons/settings-96.png", "sizes": "96x96" }] }
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<!-- index.html -->
|
|
59
|
+
<link rel="manifest" href="/manifest.json">
|
|
60
|
+
<meta name="theme-color" content="#000000">
|
|
61
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
62
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
63
|
+
<link rel="apple-touch-icon" href="/icons/icon-192.png">
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Service Worker
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
// sw.js — Cache-first strategy for static assets
|
|
70
|
+
const CACHE_NAME = 'my-app-v1';
|
|
71
|
+
const STATIC_ASSETS = ['/', '/index.html', '/styles.css', '/app.js', '/icons/icon-192.png'];
|
|
72
|
+
|
|
73
|
+
self.addEventListener('install', (event) => {
|
|
74
|
+
event.waitUntil(
|
|
75
|
+
caches.open(CACHE_NAME).then((cache) => cache.addAll(STATIC_ASSETS))
|
|
76
|
+
);
|
|
77
|
+
self.skipWaiting();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
self.addEventListener('activate', (event) => {
|
|
81
|
+
event.waitUntil(
|
|
82
|
+
caches.keys().then((keys) =>
|
|
83
|
+
Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
self.clients.claim();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
self.addEventListener('fetch', (event) => {
|
|
90
|
+
event.respondWith(
|
|
91
|
+
caches.match(event.request).then((cached) => {
|
|
92
|
+
const fetched = fetch(event.request).then((response) => {
|
|
93
|
+
const clone = response.clone();
|
|
94
|
+
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone));
|
|
95
|
+
return response;
|
|
96
|
+
});
|
|
97
|
+
return cached || fetched;
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
// Register in main app
|
|
105
|
+
if ('serviceWorker' in navigator) {
|
|
106
|
+
navigator.serviceWorker.register('/sw.js');
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 3. Web Push Notifications
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
// Request permission and subscribe
|
|
114
|
+
const registration = await navigator.serviceWorker.ready;
|
|
115
|
+
const subscription = await registration.pushManager.subscribe({
|
|
116
|
+
userVisibleOnly: true,
|
|
117
|
+
applicationServerKey: urlBase64ToUint8Array(VAPID_PUBLIC_KEY),
|
|
118
|
+
});
|
|
119
|
+
// Send subscription to your backend
|
|
120
|
+
await fetch('/api/subscribe', { method: 'POST', body: JSON.stringify(subscription) });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Build & Test
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Vite PWA plugin (vite-plugin-pwa 1.3+ supports Vite 3-8)
|
|
127
|
+
npm install vite-plugin-pwa -D
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
// vite.config.js
|
|
132
|
+
import { VitePWA } from 'vite-plugin-pwa';
|
|
133
|
+
|
|
134
|
+
export default {
|
|
135
|
+
plugins: [
|
|
136
|
+
VitePWA({
|
|
137
|
+
registerType: 'autoUpdate',
|
|
138
|
+
workbox: {
|
|
139
|
+
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
|
140
|
+
runtimeCaching: [
|
|
141
|
+
{
|
|
142
|
+
urlPattern: /^https:\/\/api\.example\.com\//,
|
|
143
|
+
handler: 'NetworkFirst',
|
|
144
|
+
options: { cacheName: 'api-cache', expiration: { maxEntries: 50, maxAgeSeconds: 3600 } },
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
manifest: { /* manifest.json content */ },
|
|
149
|
+
}),
|
|
150
|
+
],
|
|
151
|
+
};
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Build
|
|
156
|
+
npm run build
|
|
157
|
+
# Output: dist/ directory with PWA-ready files
|
|
158
|
+
|
|
159
|
+
# Test locally
|
|
160
|
+
npx serve dist # Serve over HTTP for testing
|
|
161
|
+
# For full PWA testing: deploy to HTTPS server
|
|
162
|
+
|
|
163
|
+
# Lighthouse audit
|
|
164
|
+
npx lighthouse https://myapp.com --only-categories=pwa
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Framework-Specific PWA
|
|
168
|
+
|
|
169
|
+
### Next.js (App Router)
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
// next.config.js
|
|
173
|
+
const withPWA = require('next-pwa')({
|
|
174
|
+
dest: 'public',
|
|
175
|
+
register: true,
|
|
176
|
+
skipWaiting: true,
|
|
177
|
+
});
|
|
178
|
+
module.exports = withPWA({ /* next config */ });
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Vue (Vite)
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
// Same as Vite config above — use vite-plugin-pwa
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### React (Create React App / Vite)
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# CRA: use `cra-template-pwa`
|
|
191
|
+
npx create-react-app my-app --template pwa
|
|
192
|
+
|
|
193
|
+
# Vite: use vite-plugin-pwa (recommended)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## PWA vs Native App
|
|
197
|
+
|
|
198
|
+
| Feature | PWA | Native App |
|
|
199
|
+
|---------|-----|-----------|
|
|
200
|
+
| Distribution | URL (no store) | App Store / Play Store |
|
|
201
|
+
| Install | Browser prompt | Store download |
|
|
202
|
+
| Offline | Yes (Service Worker) | Yes |
|
|
203
|
+
| Push notifications | Yes (web push) | Yes |
|
|
204
|
+
| Device access | Limited (camera, GPS, file) | Full |
|
|
205
|
+
| Performance | Good (WASM, Web Workers) | Best |
|
|
206
|
+
| Size | No install footprint | 20MB+ |
|
|
207
|
+
| Updates | Instant (on next visit) | Store review |
|
|
208
|
+
| iOS support | Limited (no full PWA on Safari < 16.4) | Full |
|
|
209
|
+
|
|
210
|
+
## Common Pitfalls
|
|
211
|
+
|
|
212
|
+
| Issue | Fix |
|
|
213
|
+
|-------|-----|
|
|
214
|
+
| PWA not installable | Ensure manifest.json is correct; serve over HTTPS; check Lighthouse PWA audit |
|
|
215
|
+
| Service Worker not updating | Use `skipWaiting()` + `clients.claim()`; change cache version |
|
|
216
|
+
| iOS push notifications not working | Requires Safari 16.4+; use web push with VAPID keys |
|
|
217
|
+
| Cache serving stale content | Use NetworkFirst for API; CacheFirst for static assets |
|
|
218
|
+
| Offline page not showing | Add fallback page in service worker `fetch` handler |
|
|
219
|
+
| Maskable icon looks wrong | Test with maskable.app; ensure safe zone is respected |
|
|
220
|
+
| Background sync not working | Only supported in Chrome/Edge; use IndexedDB for queued operations |
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# Serverless & Edge Build Sub-Skill
|
|
2
|
+
|
|
3
|
+
Build and package applications for serverless platforms and edge runtimes.
|
|
4
|
+
|
|
5
|
+
**Current versions**: AWS Lambda / Cloudflare Workers / Vercel Functions / Deno Deploy (2025-2026)
|
|
6
|
+
|
|
7
|
+
## When to Use
|
|
8
|
+
|
|
9
|
+
- Pay-per-request pricing model
|
|
10
|
+
- Auto-scaling without infrastructure management
|
|
11
|
+
- API backends with variable traffic
|
|
12
|
+
- Edge computing (low latency globally)
|
|
13
|
+
- Cron jobs / scheduled tasks
|
|
14
|
+
- Webhook handlers
|
|
15
|
+
|
|
16
|
+
## Platform Comparison
|
|
17
|
+
|
|
18
|
+
| Platform | Language Support | Cold Start | Max Duration | Best For |
|
|
19
|
+
|----------|-----------------|-----------|-------------|---------|
|
|
20
|
+
| AWS Lambda | Node/Python/Go/Rust/Java/.NET | 100–500ms | 15 min | Enterprise, complex workflows |
|
|
21
|
+
| Cloudflare Workers | JS/TS/WASM | < 1ms | 30s (CPU) / unlimited (I/O) | Edge compute, APIs |
|
|
22
|
+
| Vercel Functions | Node/Python/Go/Ruby | 100–300ms | 60s (free) / 900s (pro) | Next.js apps, frontend APIs |
|
|
23
|
+
| Deno Deploy | JS/TS | < 10ms | 50ms–60s | Lightweight APIs, edge |
|
|
24
|
+
| Netlify Functions | Node/Go | 100–500ms | 10s (free) / 26s (pro) | JAMstack apps |
|
|
25
|
+
| Azure Functions | Node/Python/C#/Java/PowerShell | 100–500ms | 10 min (consumption) | .NET ecosystem |
|
|
26
|
+
| Google Cloud Functions | Node/Python/Go/Java/.NET/Ruby | 100–500ms | 60 min (gen2) | GCP ecosystem |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## AWS Lambda
|
|
31
|
+
|
|
32
|
+
### Node.js Function
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
// handler.js (Lambda Function URL or API Gateway)
|
|
36
|
+
exports.handler = async (event) => {
|
|
37
|
+
const name = event.queryStringParameters?.name || 'World';
|
|
38
|
+
return {
|
|
39
|
+
statusCode: 200,
|
|
40
|
+
headers: { 'Content-Type': 'application/json' },
|
|
41
|
+
body: JSON.stringify({ message: `Hello, ${name}!` }),
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Package
|
|
48
|
+
zip -r function.zip handler.js node_modules/
|
|
49
|
+
|
|
50
|
+
# Deploy with AWS CLI
|
|
51
|
+
aws lambda create-function \
|
|
52
|
+
--function-name my-function \
|
|
53
|
+
--runtime nodejs22.x \
|
|
54
|
+
--handler handler.handler \
|
|
55
|
+
--zip-file fileb://function.zip \
|
|
56
|
+
--role arn:aws:iam::ACCOUNT:role/lambda-role
|
|
57
|
+
|
|
58
|
+
# Or with SAM (Serverless Application Model)
|
|
59
|
+
sam build && sam deploy --guided
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Python Function
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
# lambda_function.py
|
|
66
|
+
import json
|
|
67
|
+
|
|
68
|
+
def handler(event, context):
|
|
69
|
+
name = event.get('queryStringParameters', {}).get('name', 'World')
|
|
70
|
+
return {
|
|
71
|
+
'statusCode': 200,
|
|
72
|
+
'headers': {'Content-Type': 'application/json'},
|
|
73
|
+
'body': json.dumps({'message': f'Hello, {name}!'})
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Go Function
|
|
78
|
+
|
|
79
|
+
```go
|
|
80
|
+
package main
|
|
81
|
+
|
|
82
|
+
import (
|
|
83
|
+
"context"
|
|
84
|
+
"github.com/aws/aws-lambda-go/events"
|
|
85
|
+
"github.com/aws/aws-lambda-go/lambda"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
func handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
|
|
89
|
+
name := request.QueryStringParameters["name"]
|
|
90
|
+
if name == "" { name = "World" }
|
|
91
|
+
return events.APIGatewayProxyResponse{
|
|
92
|
+
StatusCode: 200,
|
|
93
|
+
Headers: map[string]string{"Content-Type": "application/json"},
|
|
94
|
+
Body: fmt.Sprintf(`{"message":"Hello, %s!"}`, name),
|
|
95
|
+
}, nil
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
func main() { lambda.Start(handler) }
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Build and deploy
|
|
103
|
+
GOOS=linux GOARCH=amd64 go build -o bootstrap main.go
|
|
104
|
+
zip function.zip bootstrap
|
|
105
|
+
aws lambda create-function --function-name my-go-func --runtime provided.al2023 --handler bootstrap --zip-file fileb://function.zip
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Rust Function (Custom Runtime)
|
|
109
|
+
|
|
110
|
+
```toml
|
|
111
|
+
# Cargo.toml
|
|
112
|
+
[dependencies]
|
|
113
|
+
lambda_runtime = "0.13"
|
|
114
|
+
tokio = { version = "1", features = ["macros"] }
|
|
115
|
+
serde = { version = "1", features = ["derive"] }
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```rust
|
|
119
|
+
use lambda_runtime::{service_fn, LambdaEvent, Error};
|
|
120
|
+
use serde_json::{json, Value};
|
|
121
|
+
|
|
122
|
+
async fn handler(event: LambdaEvent<Value>) -> Result<Value, Error> {
|
|
123
|
+
let name = event.payload.get("name").and_then(|v| v.as_str()).unwrap_or("World");
|
|
124
|
+
Ok(json!({ "statusCode": 200, "body": format!("Hello, {}!", name) }))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#[tokio::main]
|
|
128
|
+
async fn main() -> Result<(), Error> {
|
|
129
|
+
lambda_runtime::run(service_fn(handler)).await
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Cloudflare Workers
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Create project
|
|
139
|
+
npm create cloudflare@latest my-worker
|
|
140
|
+
cd my-worker
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
// src/index.js
|
|
145
|
+
export default {
|
|
146
|
+
async fetch(request, env, ctx) {
|
|
147
|
+
const url = new URL(request.url);
|
|
148
|
+
if (url.pathname === '/health') {
|
|
149
|
+
return new Response('OK', { status: 200 });
|
|
150
|
+
}
|
|
151
|
+
return new Response('Hello from the Edge!', { status: 200 });
|
|
152
|
+
},
|
|
153
|
+
// Scheduled handler (cron)
|
|
154
|
+
async scheduled(event, env, ctx) {
|
|
155
|
+
// Runs on cron schedule defined in wrangler.toml
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```toml
|
|
161
|
+
# wrangler.toml
|
|
162
|
+
name = "my-worker"
|
|
163
|
+
main = "src/index.js"
|
|
164
|
+
compatibility_date = "2025-01-01"
|
|
165
|
+
|
|
166
|
+
[triggers]
|
|
167
|
+
crons = ["*/5 * * * *"] # Every 5 minutes
|
|
168
|
+
|
|
169
|
+
# KV Storage
|
|
170
|
+
[[kv_namespaces]]
|
|
171
|
+
binding = "CACHE"
|
|
172
|
+
id = "your-kv-namespace-id"
|
|
173
|
+
|
|
174
|
+
# D1 Database
|
|
175
|
+
[[d1_databases]]
|
|
176
|
+
binding = "DB"
|
|
177
|
+
database_name = "my-db"
|
|
178
|
+
database_id = "your-d1-database-id"
|
|
179
|
+
|
|
180
|
+
# R2 Storage (S3-compatible)
|
|
181
|
+
[[r2_buckets]]
|
|
182
|
+
binding = "STORAGE"
|
|
183
|
+
bucket_name = "my-bucket"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# Deploy
|
|
188
|
+
npx wrangler deploy
|
|
189
|
+
|
|
190
|
+
# Test locally
|
|
191
|
+
npx wrangler dev
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Vercel Functions
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
// app/api/hello/route.js (Next.js App Router)
|
|
200
|
+
export async function GET(request) {
|
|
201
|
+
return Response.json({ message: 'Hello from Vercel!' });
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export async function POST(request) {
|
|
205
|
+
const body = await request.json();
|
|
206
|
+
return Response.json({ received: body });
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Deploy
|
|
212
|
+
vercel deploy
|
|
213
|
+
|
|
214
|
+
# Or: git push to connected repository (auto-deploy)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Deno Deploy
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
// main.ts
|
|
223
|
+
Deno.serve((req: Request) => {
|
|
224
|
+
const url = new URL(req.url);
|
|
225
|
+
if (url.pathname === "/health") {
|
|
226
|
+
return new Response("OK");
|
|
227
|
+
}
|
|
228
|
+
return new Response("Hello from Deno Deploy!");
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Deploy
|
|
234
|
+
deployctl deploy --project=my-project main.ts
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Serverless Framework (Multi-Cloud)
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
# serverless.yml
|
|
243
|
+
service: my-service
|
|
244
|
+
frameworkVersion: '3'
|
|
245
|
+
|
|
246
|
+
provider:
|
|
247
|
+
name: aws
|
|
248
|
+
runtime: nodejs22.x
|
|
249
|
+
region: us-east-1
|
|
250
|
+
|
|
251
|
+
functions:
|
|
252
|
+
api:
|
|
253
|
+
handler: handler.handler
|
|
254
|
+
events:
|
|
255
|
+
- httpApi:
|
|
256
|
+
path: /{proxy+}
|
|
257
|
+
method: '*'
|
|
258
|
+
- schedule:
|
|
259
|
+
rate: rate(1 hour)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
npm install -g serverless
|
|
264
|
+
serverless deploy
|
|
265
|
+
serverless info # Get endpoint URLs
|
|
266
|
+
serverless logs -f api # View logs
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Selection Guide
|
|
272
|
+
|
|
273
|
+
| Scenario | Recommended Platform | Why |
|
|
274
|
+
|----------|---------------------|-----|
|
|
275
|
+
| Next.js app | Vercel | First-class Next.js support |
|
|
276
|
+
| Global API with low latency | Cloudflare Workers | Edge-first, < 1ms cold start |
|
|
277
|
+
| Enterprise backend | AWS Lambda + API Gateway | Full AWS ecosystem |
|
|
278
|
+
| .NET backend | Azure Functions | Native .NET support |
|
|
279
|
+
| Cron jobs / scheduled tasks | Any (all support cron) | Pick based on existing infra |
|
|
280
|
+
| AI inference at edge | Cloudflare Workers AI | GPU at the edge |
|
|
281
|
+
| Simple webhook handler | Vercel/Netlify Functions | Easiest setup |
|
|
282
|
+
| High-memory workloads | AWS Lambda (10GB) | Highest memory allocation |
|
|
283
|
+
|
|
284
|
+
## Common Pitfalls
|
|
285
|
+
|
|
286
|
+
| Issue | Fix |
|
|
287
|
+
|-------|-----|
|
|
288
|
+
| Cold start too slow | Use provisioned concurrency (AWS); keep functions small |
|
|
289
|
+
| Function timeout | Break into smaller functions; use async queues (SQS/Queues) |
|
|
290
|
+
| Package too large | Use tree-shaking; exclude dev deps; use Lambda layers |
|
|
291
|
+
| Environment variables not available | Set in platform dashboard; use secrets manager |
|
|
292
|
+
| Database connection exhaustion | Use connection pooling (RDS Proxy, Neon, PlanetScale) |
|
|
293
|
+
| CORS errors | Add CORS headers in function response |
|
|
294
|
+
| Webhook replay attacks | Verify webhook signatures (Stripe, GitHub) |
|
|
295
|
+
| Edge runtime limitations | No filesystem access; limited Node.js APIs; no native modules |
|