Skip to main content

Requirements

Project Structure

my-api-fastify/
├── src/
│   ├── server.js
│   └── routes/
│       └── index.js
├── package.json
└── vertracloud.config

Configuration

package.json

{
  "name": "my-api-fastify",
  "version": "1.0.0",
  "main": "src/server.js",
  "scripts": {
    "start": "node src/server.js"
  },
  "dependencies": {
    "fastify": "^5.0.0",
    "@fastify/cors": "^10.0.0"
  }
}

vertracloud.config

MAIN=src/server.js
START=npm start
VERSION=recommended

Complete Example

const fastify = require('fastify')({ logger: true });
const cors = require('@fastify/cors');

// Plugins
fastify.register(cors, { origin: '*' });

// Routes
fastify.get('/', async (request, reply) => {
  return { message: 'Fastify on Vertra Cloud!' };
});

fastify.get('/health', async (request, reply) => {
  return { status: 'healthy', uptime: process.uptime() };
});

// Start server
const start = async () => {
  try {
    const port = process.env.PORT || 80;
    await fastify.listen({ port, host: '0.0.0.0' });
  } catch (err) {
    fastify.log.error(err);
    process.exit(1);
  }
};

start();
Use host: '0.0.0.0' in fastify.listen(). Fastify by default listens only on localhost, preventing external connections inside the container.

Deploy

  1. Exclude node_modules from the project
  2. Compress into ZIP or connect via GitHub
  3. Select Node.js as language
  4. Configure memory (256MB for simple APIs, 512MB+ for heavy processing APIs)
  5. Click “Create Application”

Available Versions

VersionStatusDescription
24.5.0LatestNode.js 24.5.0 (latest version)
22.18.0RecommendedNode.js 22.18.0 LTS (recommended for production)
20.18.0StableNode.js 20.18.0 with extended support

Differences from Express

AspectExpressFastify
PerformanceGoodSuperior (up to 2x faster)
ValidationManual or middlewareBuilt-in with JSON Schema
PluginsSimple middlewareEncapsulated plugin system
TypeScriptVia @typesNative support

Notes

  • Fastify has built-in schema validation — use it to ensure request integrity
  • For TypeScript, compile to JavaScript before deployment
  • The built-in logger from Fastify appears in dashboard real-time logs
  • Enable auto-restart for production applications