feat(deploy): a serverless entry, and migrations as a deploy step - #22
Closed
fajarhide wants to merge 1 commit into
Closed
feat(deploy): a serverless entry, and migrations as a deploy step#22fajarhide wants to merge 1 commit into
fajarhide wants to merge 1 commit into
Conversation
Ten connections suits a server that owns its database. A 2 GB host wants fewer, and so does anything sitting behind a pooler that is already doing the sharing. Neither is worth editing code and building an image for.
fajarhide
force-pushed
the
feat/vercel-gateway
branch
from
August 17, 2026 06:05
8ba4786 to
db2413f
Compare
Owner
Author
|
Superseded by the trimmed version. The gateway runs beside its Postgres rather than on Vercel, so the entry point and vercel.json here would be a deploy target nobody runs and nothing tests. Only DATABASE_POOL_MAX survives. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three changes that stand between the gateway and a serverless deploy.
api/index.tsbuilds the pool and the provider registry at module scope, so theysurvive between invocations, and exports the Express app
createServeralreadyreturns.
vercel.jsonroutes every path to it and runsnpm run migrateat build.Migrations no longer happen at cold start.
scripts/migrate.tsreads onlyDATABASE_URL, deliberately notloadConfig, so the deploy step never carriesVAULT_KEYfor work that does not use it.main.tskeeps its boot migration forself-host, where one process starts once and owns the database.
DATABASE_POOL_MAXmakes the pool size an env var. Ten connections per instance isright for one long lived server and wrong when every instance opens its own pool
against a shared ceiling.
Verified against a real Postgres:
Still needed before this is live, and none of it belongs in the repo: a pooled
DATABASE_URL, the environment set on Vercel, and a second GitHub OAuth App forproduction, since a GitHub OAuth App takes only one callback URL.