Our great sponsors
-
Nodemon.io
Monitor for any changes in your node.js application and automatically restart the server - perfect for development
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
fastify-example
This project is a small but feature complete application build with Fastify and Svelte, and it aims to show all the core concepts of Fastify, best practices, and recommendations.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
ajv
The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)
You can check out the source code or follow along in this post.
nodemon is a dev dependency that'll monitor your file changes and restart your server automatically.
fastify-example
fastify-example-todo
From the documentation, fastify is a fast and low overhead web framework for Node.js.
To interface with postgreSQL database we need node-postgres or the pg driver.
On the first line, we create a fastify instance and enable logging, fastify uses pino as its logger. We then define a GET route method, specify a homepage endpoint '/' and pass in the route handler function which responds with the object {hello: 'world'} when we make a get request to the homepage.
Fastify uses Ajv to validate requests. We expect the client to always send the name of the todo by adding it in the required property array.