
Product
Reachability for Ruby Now in Beta
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.
@uscreen.de/fastify-app
Advanced tools
Opinionated combination of base packages to bootstrap a fastify app
Opinionated feature pack (of packages) to bootstrap a fastify app
name, version and root-path read from package.jsonconfigAll those features are ready setup with defaults, that may be customized further to your likings.
Easy start by pnpm create cli command to create a new fastify-app from scratch instead of manually setting up a new fastify instance, like so:
$ pnpm create @uscreen.de/fastify-app new-app
It will create a directory called new-app inside the current folder.
Inside that directory, it will generate the initial project structure:
new-app
├── .env
├── .env.example
├── .gitignore
├── README.md
├── app
│  ├── app.js
│  ├── config.js
│  ├── plugins
│  │  └── noop.js
│  ├── schemas.js
│  ├── server.js
│  └── services
│  └── noop.js
├── package.json
└── test
   ├── app
    │  └── noop.test.js
   └── helper.js
$ pnpm add @uscreen.de/fastify-app # or use npm -i
Minimal example:
import defaultApp from '@uscreen.de/fastify-app'
// register with defaults
fastify.register(defaultApp)
With default server options for logging, etc.
import Fastify from 'fastify'
import defaultApp, { options } from '@uscreen.de/fastify-app'
// create fastify instance with default options
const fastify = Fastify(options())
// register with defaults
fastify.register(defaultApp)
This enables all default features and exposes some extra routes, like:
GET /docs - autogenerated OpenAPI 3.0 documentation of all endpointGET /health - healthcheck endpoint return HTTP 200 {"status":"ok"}All options get validated and defaulted to a defined json-schema you can check in config.js Overview of options:
| option | Description | Default | Example |
|---|---|---|---|
| autoloads | array of directories @fastify/autoload should load your fastify plugins from. Please consider reading Loading order of your plugins | [] | ['./plugins', './services'] |
| swagger | object configuring @fastify/swagger to generate Swagger2/OpenAPI3 docs from your routes | {exposeRoute: true, openapi:{}} | {exposeRoute: '/docs'} |
| swagger.scalar | object configuring @scalar/fastify-api-reference to configure the scalar client. Read Configuration for more details. | {} | {theme: 'solarized'} |
| health | object configuring under-pressure to provide a monitoring healthcheck route for your app | {exposeStatusRoute: true} | {exposeStatusRoute: '/health'} |
| contentSecurityPolicy | object configuring helmet to set CSR headers on each response | {contentSecurityPolicy: false} | {contentSecurityPolicy: {directives: {defaultSrc: ["'self'"]}}} |
decorate your healthCheck option with a custom function returning truthy on success, ie.:
import fastifyApp from '@uscreen.de/fastify-app'
import fp from 'fastify-plugin'
import schemas from './schemas.js'
export default fp(async (fastify, opts, next) => {
/**
* add schemas
*/
fastify.register(schemas)
/**
* configure healthCheck function for health
*/
opts.health = {
...opts.health,
healthCheck: async () => {
/**
* check for proper mongo conenction
*/
const collections = await fastify.mongo.db.collections()
/**
* check for proper nats connection
*/
const natsConnected = await fastify.nats.testConnection()
/**
* check for proper redis connection
*/
const redisConnected = await fastify.redis.ping()
/**
* true if all tests passed
*/
return collections && natsConnected && redisConnected && true
}
}
/**
* register app
*/
fastify.register(fastifyApp, opts)
next()
})
config.logger.name = 'my-app'options method pass through trustProxy property.options method pass through ajv property.fastify.version which brokefastify.app.version, fastify.app.name, and fastify.app.rootfastify.<decorator> if already declaredhealth <-> healthCheck@uscreen.de/create-fastify-appLicensed under MIT.
Published, Supported and Sponsored by u|screen
FAQs
Opinionated combination of base packages to bootstrap a fastify app
We found that @uscreen.de/fastify-app demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.

Research
/Security News
Malicious npm packages use Adspect cloaking and fake CAPTCHAs to fingerprint visitors and redirect victims to crypto-themed scam sites.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.