spfn 0.2.0-beta.63 → 0.2.0-beta.65
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/dist/index.js +378 -238
- package/dist/templates/vercel/npmrc +4 -0
- package/dist/templates/vercel/route.ts +53 -0
- package/dist/templates/vercel/vercel.json +6 -0
- package/package.json +4 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
@spfn:registry=https://git.superfunction.xyz/api/packages/superfunction/npm/
|
|
2
|
+
@superself:registry=https://git.superfunction.xyz/api/packages/superfunction/npm/
|
|
3
|
+
//git.superfunction.xyz/api/packages/superfunction/npm/:_authToken=${GITEA_NPM_TOKEN}
|
|
4
|
+
//git.superfunction.xyz/api/packages/superfunction/npm/:always-auth=true
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel serverless adapter for the SPFN Hono API.
|
|
3
|
+
*
|
|
4
|
+
* The SPFN-specific bootstrap lives in the core: `createServerlessApp()`
|
|
5
|
+
* (from `@spfn/core/server`) returns a listen-free, memoized Hono app with the DB
|
|
6
|
+
* initialized in-handler and the periodic health-check disabled. `hono/vercel`'s
|
|
7
|
+
* `handle()` turns it into Vercel Functions. `startServer()` / `spfn start` (the
|
|
8
|
+
* always-on path) is unaffected.
|
|
9
|
+
*
|
|
10
|
+
* The SPFN app is mounted under `/api/backend` so it coexists with Next.js routes on
|
|
11
|
+
* a single Vercel origin. Point the RPC proxy at the same origin in production:
|
|
12
|
+
* SPFN_API_URL = https://<deployment>/api/backend
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Hono } from 'hono';
|
|
16
|
+
import { handle } from 'hono/vercel';
|
|
17
|
+
import { createServerlessApp } from '@spfn/core/server';
|
|
18
|
+
import serverConfig from '@/server/server.config';
|
|
19
|
+
|
|
20
|
+
// SPFN needs Node APIs (pg, native bcrypt) — the edge runtime cannot host it.
|
|
21
|
+
export const runtime = 'nodejs';
|
|
22
|
+
export const dynamic = 'force-dynamic';
|
|
23
|
+
|
|
24
|
+
// The Vercel Supabase integration injects POSTGRES_URL (Supavisor transaction pooler)
|
|
25
|
+
// but not DATABASE_URL, which is what SPFN reads. Map it so the app connects.
|
|
26
|
+
process.env.DATABASE_URL ??= process.env.POSTGRES_URL;
|
|
27
|
+
|
|
28
|
+
let handlerPromise: Promise<(req: Request) => Response | Promise<Response>> | undefined;
|
|
29
|
+
|
|
30
|
+
function getHandler()
|
|
31
|
+
{
|
|
32
|
+
if (!handlerPromise)
|
|
33
|
+
{
|
|
34
|
+
handlerPromise = createServerlessApp(serverConfig).then((spfn) =>
|
|
35
|
+
handle(new Hono().route('/api/backend', spfn)),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return handlerPromise;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function dispatch(req: Request): Promise<Response>
|
|
43
|
+
{
|
|
44
|
+
return (await getHandler())(req);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const GET = dispatch;
|
|
48
|
+
export const POST = dispatch;
|
|
49
|
+
export const PUT = dispatch;
|
|
50
|
+
export const PATCH = dispatch;
|
|
51
|
+
export const DELETE = dispatch;
|
|
52
|
+
export const OPTIONS = dispatch;
|
|
53
|
+
export const HEAD = dispatch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spfn",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.65",
|
|
4
4
|
"description": "Superfunction CLI - Add SPFN to your Next.js project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"prepack": "node -e \"require('fs').copyFileSync('../../LICENSE','LICENSE')\"",
|
|
18
18
|
"dev": "tsup --watch",
|
|
19
19
|
"type-check": "tsc --noEmit",
|
|
20
|
-
"publish:alpha": "
|
|
21
|
-
"publish:beta": "
|
|
22
|
-
"publish:latest": "
|
|
20
|
+
"publish:alpha": "node ../../scripts/publish-package.mjs alpha",
|
|
21
|
+
"publish:beta": "node ../../scripts/publish-package.mjs beta",
|
|
22
|
+
"publish:latest": "node ../../scripts/publish-package.mjs latest"
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"spfn",
|