Node Express API¶
A REST API built with Node.js and Express. Single container, single service, no database -- demonstrating how to deploy a Node.js application on AppMecca.
Overview¶
| Repository | git@gitlab.com:appmecca-sample-apps/node-express-api.git |
| Tech Stack | Node.js 20 / Express |
| Services | api (port 3000) |
| Database | None |
| Cache | None |
| URL Pattern | https://node-express-api-api.{env}.appmecca.net |
What This App Demonstrates¶
- Deploying a Node.js application on AppMecca
- API service naming conventions (using
apiinstead ofweb) - Standard Express project structure with health endpoint
- Production Node.js container patterns (
npm ci --only=production)
appmecca.yaml¶
containers:
- name: api
dockerfile: Dockerfile
context: .
deploy:
- name: api
container: api
port: 3000
health_check:
path: /health
The configuration follows the same pattern as any single-container app. The service is named api rather than web to reflect that it serves a REST API, but this is purely a naming choice -- AppMecca treats them identically.
Step-by-Step Deployment¶
1. Register the app¶
2. Build the container¶
Expected output
3. Deploy¶
Expected output
4. Verify¶
mecca queue status takes a queue action id, so to check on the app
itself use:
Test the API directly:
Key Concepts¶
Service naming¶
The service name in appmecca.yaml is a label you choose. Common conventions:
| Name | Typical use |
|---|---|
web |
General-purpose web server |
api |
REST or GraphQL API |
frontend |
Client-facing UI |
backend |
Server-side logic |
The name appears in logs, status output, and in the URL. The service name is always part of the hostname — an app with a single service named api is reached at node-express-api-api.{env}.appmecca.net, not at a bare node-express-api.{env}.appmecca.net. Pick the name with that in mind.
Node.js production containers¶
A production Node.js Dockerfile typically uses npm ci --only=production to install only production dependencies, skipping devDependencies like test frameworks and linters. This keeps the image smaller and reduces the attack surface.
Use a .dockerignore file
Add node_modules, .git, and test directories to .dockerignore to prevent them from being copied into the build context. This speeds up builds and keeps images clean.
Reading build logs¶
mecca build trigger returns as soon as the build is queued. To read the
output, take the build id it printed and pass it to mecca build logs:
mecca build status -e dev <build-id> reports whether it is still running,
succeeded, or failed.
What's Next?¶
- Hello Flask -- see the same pattern in Python
- Go Web Server -- see the same pattern with a compiled language
- App with Database -- add PostgreSQL to your API
- Environment Variables -- inject configuration into your app
- Service Management -- restart, stop, and view logs