Skip to content

Configuration ​

Everything is configured in one object, passed to new Lyn(). Every option is optional: new Lyn() alone is a working app.

ts
const app = new Lyn({
  env: {
    port: { name: "PORT", type: "number" },
  },
  database: { schema },
  cors: { origin: ["https://app.example.com"] },
  rateLimit: { max: 100 },
  server: { hostname: "0.0.0.0", allowedHosts: ["api.example.com"] },
});

Application ​

OptionWhat it doesPage
envDeclares the environment variables your app needs, checked and typed at startupEnvironment variables
databaseConnects Postgres, with a typed db in every handlerDatabase

Security ​

OptionWhat it doesPage
corsLets browsers on other domains call your APICORS
rateLimitLimits how many requests each client may sendRate limiting

Server ​

OptionDefaultPage
server.hostname"127.0.0.1", this machine onlyWho can reach it
server.allowedHosts127.0.0.1, localhost, ::1Who can reach it
server.maxBodyBytes1048576 (1 MiB)Limits
server.requestTimeoutMs30000 (30 seconds)Limits
start.hideLynLogofalseStarting

Outside the constructor ​

  • Logging is configured with the NODE_ENV and LOG_LEVEL environment variables. See Logging.
  • lyn.config.ts only tells the lyn db commands where your schema and migrations are. See Migrations.

Released under the MIT License.