Categories
Node.js Node.js Quick Tips Quick Tips

Command-line argument parsing with Node.js core

3 min read

Categories
Node.js

Deploying a Node app and Postgres database to Fly.io

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 […]

Categories
Fastify Node.js

Use Fastify hooks to set headers on every response

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

Categories
Node.js What's new in Node.js core?

What’s new in Node.js core? March 2022 edition

3 min read 🌟 New features 🎞️ Video walkthrough 💎 Other notable features 📅 Node.js releases

Categories
Node.js

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

Categories
Node.js Videos

Talk: Improving your applications with AbortController

< 1 min read

Categories
Node.js

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

Categories
Node.js

Guidelines for choosing a Node.js framework

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

Categories
Fastify Videos

Workshop recording: Get Started with Fastify

< 1 min read

Categories
Node.js What's new in Node.js core?

What’s new in Node.js core? September 2021

< 1 min read

Categories
Fastify Learning Fastify Node.js Videos

Learning Fastify: How to migrate your app from Express to Fastify

< 1 min read Links

Categories
Express Node.js

How does middleware work in Express?

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

Categories
Fastify Node.js

How to migrate your app from Express to Fastify

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 […]

Categories
Node.js

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 […]

Categories
Fastify Node.js Videos

Talk: Make the most of modern JavaScript with Fastify (2021-02-25)

< 1 min read

Categories
Node.js

Are you using promises and async / await safely in Node.js?

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 […]

Categories
Fastify Learning Fastify Node.js Videos

Learning Fastify: Create a proxy server for API authentication

< 1 min read Links

Categories
API Essentials Fastify Node.js

How to securely call an authenticated API from your front end

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

Categories
ECMAScript modules Node.js

What you need to know about ES modules in Node.js

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 […]

Categories
Fastify Node.js Videos

Trying out HTTP Toolkit with fastify-http-proxy

< 1 min read Links

Categories
Express Node.js

Send awesome structured error responses with Express

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 […]

Categories
Express Node.js

How to create an error handler for your Express API

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 […]

Categories
Express Node.js

How to handle request validation in your Express API

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

Categories
Node.js

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

Categories
Express Node.js

How to send consistent error responses from your Express API

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”.

Categories
Express Node.js

How to fix those confusing CORS errors when calling your Express API

6 min read

Categories
ECMAScript modules Node.js

Node.js now supports named imports from CommonJS modules, but what does that mean?

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!

Categories
Express Node.js

5 best practices for building a modern API with Express

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

Categories
Node.js

What is a good directory structure for a monorepo with a Node.js back end and React front end?

3 min read

Categories
Express Node.js

How can I handle common checks across different endpoints in an Express application?

3 min read