Node Express API
A small Express API returns its Node.js version, reports its health, and lets you list or add todos. Tokay gives it a live URL as one Web Service.
Last updated
AI agent? Start with llms.txt.
This is the familiar Express shape many Node.js projects start with. You can deploy the ordinary server and package.json without teaching the app about Tokay.
- Runtime
- Node.js
- Framework
- Express
- Service types
- Web Service
- Resources
- None
- Required secrets
- None
What it does
Open the root route to see which Node.js runtime is serving your app.
The /todos route starts with three sample items. Send it a title with POST and the API returns the new todo with its ID.
Send an empty title and you get a clear validation error. The /health route gives you a small liveness check.
Deploy it
Bring this folder to Tokay any way you like. Hand it to your AI assistant, drag the unzipped folder in under Add code, or push it with Git. Tokay figures out the rest.
Haven't connected your assistant yet? Set it up once, then ask it to deploy this example. Agents can use Tokay MCP at https://mcp.tokay.io/mcp or the Tokay API, and our agent instructions cover both.
New to Tokay? The getting started guide walks you through your first deploy.
Try it
Replace the placeholder with your live URL, add one todo, then fetch the list.
export APP_URL="https://your-app.tokay.app"
curl -X POST "$APP_URL/todos" \
-H 'Content-Type: application/json' \
-d '{"title":"ship the next thing"}'
curl "$APP_URL/todos"
Your new todo appears in the list. Deploy again and the three samples return because this starter deliberately keeps data in memory.
How it works
You can keep the same Express entry point you use locally. Tokay installs the packages, supplies PORT, starts the server, and routes the live URL to it.
Secrets
You can call every route without a secret or an outside account.
Grow from here
Try the PostgreSQL task tracker when you want todos to survive a restart.
Source code
package.json Raw
{
"name": "tokay-node-express-api",
"version": "1.0.0",
"private": true,
"type": "commonjs",
"scripts": {
"start": "node server.js"
},
"engines": {
"node": ">=22"
},
"dependencies": {
"express": "^5.1.0"
}
}
server.js Raw
const express = require('express');
const app = express();
const todos = [
{ id: 1, title: 'deploy this ✓' },
{ id: 2, title: 'add a database' },
{ id: 3, title: 'tell a friend' },
];
app.use(express.json());
app.get('/', (_request, response) => response.json({
message: 'Hello from Express',
runtime: `Node.js ${process.version}`,
}));
app.get('/health', (_request, response) => response.json({ ok: true }));
app.get('/todos', (_request, response) => response.json(todos));
app.post('/todos', (request, response) => {
const title = String(request.body?.title || '').trim();
if (!title) return response.status(400).json({ error: 'title is required' });
const todo = { id: todos.at(-1)?.id + 1 || 1, title };
todos.push(todo);
return response.status(201).json(todo);
});
const port = Number(process.env.PORT || 3000);
app.listen(port, '0.0.0.0', () => console.log(`Express API listening on port ${port}`));
Built from revision 259b82f