Zum Inhalt springen
GigadriveDocs

Fastify

What Gigadrive Network detects for a Fastify project, which file it runs as the Function, and the defaults it applies.

Gigadrive Network detects Fastify from a fastify entry in the dependencies or devDependencies of your root package.json. Your server becomes one Function that answers every path.

Defaults

SettingValue
Runtimenode-22
Memory128 MB
Max duration30 seconds
Route/* to the resolved entrypoint
EnvironmentNODE_ENV=production
Buildyour package.json build script

Fastify is detected ahead of Express and behind Hono and Elysia, so a project depending on more than one of them resolves to the higher-priority framework.

The entrypoint

The preset starts from src/index.ts and then resolves the real server file from your project. The first candidate that exists on disk wins:

  1. main in package.json.
  2. The file argument of scripts.start, when that script is a plain node, bun run, tsx or ts-node invocation.
  3. src/index.ts, then index.js, src/index.js, index.ts, app.js, src/app.js, server.js, src/server.js, app.ts, src/app.ts, server.ts, src/server.ts.

The Node runtime executes JavaScript. A TypeScript Fastify project has to build to JavaScript and point main at the compiled file, otherwise the resolved src/index.ts will not run.

Call await app.listen(...) in that file, or export the http.Server it wraps. The server is captured during import and requests are forwarded to it, so the port and host you pass are ignored. Fastify bootstraps asynchronously in most projects, and a listen() that fires up to 15 seconds after the import completes is still captured.

Changing the defaults

version: 4
functions:
  dist/server.js:
    runtime: node-22
    memory: 512
    max_duration: 60

A functions block replaces every entrypoint the preset produced, and settings you leave out fall back to the config file's defaults of memory: 128 and max_duration: 30. Declaring your own routes likewise replaces the preset's /* route.

Fastify documents its own API at fastify.dev.