The short answer
To deploy an Express API, give your coding agent the sentence below. Antideploy finds Express in your package.json, runs npm run start, and sends traffic to the port in the PORT variable. If your code needs Postgres, it creates a database and sets DATABASE_URL. You need three things in your code: a start script, a server that reads PORT, and a database connection that reads DATABASE_URL.
Say this to your coding agent
Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.
What Antideploy detects
-
Express. Detected from the
expressdependency. Fastify, Koa, NestJS and hapi are detected the same way. -
The start command. A
Procfileweb:line wins. Otherwise Antideploy runs yourstartscript withnpm run start. Without either, it cannot tell how to run the app and says so. -
The port. It starts your app with
PORTset. Your code must use it. -
The versions. The Node.js version comes from
engines.nodeinpackage.json, a.nvmrcor a.node-versionfile. -
The database. A
pg,postgres,@neondatabase/serverlessor@vercel/postgresdependency, or Prisma or Drizzle, means Postgres.
What your code needs
import express from "express";
import pg from "pg";
const app = express();
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
app.get("/health", (req, res) => res.send("ok"));
const port = process.env.PORT || 3000;
app.listen(port, "0.0.0.0");
{
"scripts": { "start": "node server.js" }
}
If you write TypeScript, add a build script that compiles it and point start at the compiled file, for example node dist/server.js. A start script that needs a tool kept only in devDependencies, such as tsx or ts-node, can fail, because development dependencies are removed from the image after the build.
Step by step
-
Check the three things
Your project has a
startscript, the server readsPORT, and the database is read fromDATABASE_URL. -
Paste the sentence and approve one link
Your agent creates the app, and a Postgres database if your code needs one, and writes the connection details into your
.envwithout printing them. The same database serves local testing and the live app. -
Deploy and open the link
Antideploy installs with
npm ciwhen there is apackage-lock.json, runs your build, runs your migration command if it found one, starts the app, checks that it answers and opens it.
Migrations
If you use an ORM with migrations, Antideploy detects the command and runs it before the new version goes live. A failed migration fails the deploy, so a broken schema never goes live.
- Prisma runs
npx prisma migrate deploywhen you have a migrations folder, andnpx prisma db pushwhen you do not - Drizzle runs
npx drizzle-kit migrate - If a migration fails because
prismaordrizzle-kitis not found, move it intodependenciesinpackage.json
Common problems
-
The app never starts listening. The server ignores
PORT, or it listens on127.0.0.1. See the full fix. -
The lock file is out of date. See npm ci can only install packages when package.json and package-lock.json are in sync.
-
Data disappears after a deploy. You used SQLite or saved uploads to disk. Use Postgres and a bucket instead.
-
A timer never fires. A scheduler inside the app, such as
node-cron, cannot run while the app sleeps. Use a scheduled job.