3 min read
Author: Simon Plenderleith
6 min read Jump links Prepare the application for deployment Configure the Node.js server to listen on all network interfaces Set a Node.js version in package.json Set up the Fly CLI We’ll use the Fly CLI for creating, configuring and deploying our application to Fly. We can follow the Installing flyctl documentation to install the Fly CLI. Once […]
4 min read Jump links Fastify hooks and encapsulation contexts Example of an onSend hook Set headers for a collection of routes Set headers for all server routes Approach 1: Register an onSend hook in the server’s root context Approach 2: Register an onSend hook inside a plugin and wrap it with fastify-plugin Useful links
3 min read 🌟 New features 🎞️ Video walkthrough 💎 Other notable features 📅 Node.js releases
The Fetch API in Node.js
< 1 min read Example Support in Node.js When can you use it in production? Related links
< 1 min read Example Support in Node.js When can you use it in production? Related links
< 1 min read Example: Trigger an abort signal with a reason (can be any value) Support in Node.js When can you use it in production? Related links
2 min read Example A: Static import with JSON import assertion Example B: Dynamic import with JSON import assertion Support in Node.js When can you use it in production? Related links
2 min read Example A Example B Support in Node.js When can you use it in production? Related links
< 1 min read Example of an object being deep cloned Support in Node.js When can you use it in production? Related links
2021 year in review
8 min read Jump links A year of firsts Client work Technical writing Products Ebook: Express API Validation Essentials Workshop: Node Validation Essentials Traditional book publishing Content Twitter Blog posts Videos Mailing list Plans for 2022
Get started with validation in Node.js
4 min read A powerful validation duo Creating a schema and validating data Schema generation Try it yourself Wrapping up Further reading
< 1 min read
How to cancel an HTTP request in Node.js
5 min read The Abort API Cancelling an HTTP request with an AbortSignal Support for cancelling HTTP requests Wrapping up
7 min read Jump links What’s your use case? Framework styles Support for promises and async / await Documentation Practical examples Community and ecosystem Project health Conclusion
< 1 min read
< 1 min read
< 1 min read
< 1 min read Example Support in Node.js Related links
2 min read timers/promises module stream/promises module readline/promises module fs/promises module dns/promises module
< 1 min read
< 1 min read Links
5 min read Jump links The middleware pattern Middleware syntax The two types of middleware Plain middleware Error handling middleware Using middleware At the route level At the router level At the application level Wrapping up
12 min read Jump links What are the benefits of migrating from Express to Fastify? How to Migrate an API with Confidence Transitioning from Express to Fastify with fastify-express Our Example Express Application Required dependencies The router module The app module The server module Running our application Migrating Our Application from Express to Fastify Required dependencies Refactoring our […]
Notes from CityJS Conference 2021
17 min read Jump links Talk: Deno and TypeScript: The Good, The Bad and The Ugly Talk: Supercharge your JavaScript with WebAssembly Talk: New and experimental features in Node.js core Talk: 10 secrets to improve Node.js Security Talk: The Third Age of JavaScript Talk: Next-gen Frontend tooling Talk: Authentication, authorisation and security for modern client-side applications Talk: A […]
2 min read Server creation and configuration is quite similar Fastify plugins are configured a little differently to Express middleware Express routes won’t show up when you call fastify.printRoutes() Fastify automatically serializes objects and arrays to JSON when you send them
< 1 min read
< 1 min read
5 min read Jump links Support for async code in Node.js What does framework “native support” for async code look like? What happens when a framework doesn’t natively support async code? Which Node.js frameworks natively support async code? How to write async code safely in Node.js Build new projects with a framework which natively supports it Migrate existing […]
< 1 min read
< 1 min read Links
5 min read Jump links Request flow with a proxy server Create a server with Fastify Add and configure the fastify-http-proxy plugin Add an API key to proxied requests HTTP request header URL query string Conclusion
7 min read Jump links Several names for the same thing Which versions of Node.js have full support for ES modules? Why are ECMAScript modules marked as ‘Experimental’ in the Node.js documentation? ES and CommonJS modules play nice together (mostly) Use ES modules when you start a new Node.js project It’s probably not worth migrating your existing Node.js […]
< 1 min read
< 1 min read Links
9 min read Jump links Introducing the ‘Problem Details for HTTP APIs’ specification Problem types and Problem details objects Example problem details response More details, clearer problems Breakdown of a problem details object How to send problem details responses with Express Define problem types and map them to JavaScript error classes Look up the problem details for an […]
< 1 min read
< 1 min read
7 min read Jump links Getting errors to error handler middleware Creating an error handler Error handler concerns Error handler middleware function Error handler helper functions Applying the error handler middleware Example error response Next steps Getting errors to error handler middleware Creating an error handler Error handler concerns Error handler middleware function Error handler helper functions Applying […]
< 1 min read
Week Notes #6
2 min read
< 1 min read
Week Notes #5
1 min read What went well this past week? I received an email from one of my subscribers thanking me for the newsletter which I send out weekly-ish. They said a bunch of very kind things that made me grin from ear to ear and it absolutely made my Friday. Metrics such as open rates, click throughs etc. […]
< 1 min read
9 min read Jump links Getting to grips with JSON Schema Why should I use JSON Schema and not validation library X? How to integrate validation with JSON schemas into your application Pulling it all together Wrapping things up Handy JSON Schema links
< 1 min read
< 1 min read
Week Notes #4
< 1 min read
2 min read
< 1 min read
< 1 min read
Notes from NodeConf Remote 2020
9 min read Talk: Aaaaaaaaaaaaaah, They’re Here! ES Modules in Node.JS Talk: Can we double HTTP client throughput? Talk: AsyncLocalStorage: usage and best practices Talk: Examining Observability in Node.js Talk: Node.js startup performance
< 1 min read
Week Notes #3
< 1 min read
Week Notes #2
2 min read
< 1 min read
6 min read When you’re building an API with Express it can be difficult to know how to send consistent error responses. The framework doesn’t seem to provide any special features for this, so you’re left to figure it out on your own. At some point you’ll probably find yourself wondering if you’re doing it “the right way”.
< 1 min read
Week Notes #1
3 min read
< 1 min read
6 min read
< 1 min read
< 1 min read
< 1 min read
2 min read
5 min read Node.js v14.13.0 introduces support for named imports from CommonJS modules. Sounds great, right? But I realised I had no idea what this actually meant. Join me on my journey of discovery!
< 1 min read
4 min read
4 min read
4 min read Jump links Enable the full use of promises and async / await 2. Validate request data with JSON Schema 3. Use an existing format for error responses 4. Send CORS response headers so web pages can call your API 5. Separate your concerns
3 min read
3 min read