Options and durations
Every Dotpress function that takes options follows the same rules.
Unknown options are rejected
A misspelled option would otherwise be ignored without a word: middleware instead of middlewares, and a route runs without its authentication. Dotpress throws a TypeError that names the option instead, when the app starts:
This applies to createApp(), the routes (their schema and meta too), the error helpers, the console logger, the adapters and their Lambda handlers, OpenAPI, the test helpers, and the auth, mailer, events and cache services. TypeScript reports most of these mistakes first; the check catches the others, in JavaScript or with an object built at runtime.
Durations
An option typed Duration takes a number of seconds, fractions allowed, or a string with a unit:
The units are ms, s, m, h and d, with no space and no combination ('1h30m' is refused). Negative numbers are refused too.
The Duration type and parseDuration(), which converts a duration to milliseconds, are exported by @dotpress/core, for the options of your own code: