#javascriptJavaScript Data Type Check CheatsheetJavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions. MDN Web Docs - javascript Detailed in this post are common JavaScript data type checks, pitfalls and idiomatic workarounds. ...
#jamstack #css #tailwind #deploymentTailwind CSS 1.x impressions, development and production setup for static sites with Tailwind CLI and PurgeCSS CLIHow to set Tailwind CSS up with a static site hosted on Netlify See the full starter repository at github.com/HugoDF/netlify-lambda-tailwind-static-starter Tailwind CSS is “a utility-first CSS framework for rapidly building custom designs”. I’ll be walking through my first ...
#javascript #jest #testing #nodeJest ignore or exclude file/function/statement from test coverageIn computer science, test coverage is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs. Code coverage - Wikipedia Code coverage is usually used as a quality metric for software eg. “Our code has to have 80% ...
#node #serverless #javascript #automation #deploymentSuper-powered newsletter content with Pocket and Netlify LambdaAn example Netlify Lambda to fetch all “newsletter” posts from Pocket. Pocket is an application and web service for managing a reading list of articles from the Internet. It’s quite widely used and tightly integrated into the Firefox browser. I find that I use it extensive ...
#javascript #node #jest #testing #MongoDBAvoiding recursion pitfalls: MongoDB nested query clause addition and removalA case-study on where recursion can be useful for enterprise Node.js applications and how to avoid its common pitfalls like RangeError: Maximum call stack size exceeded. The full repository for this post is on GitHub: github.com/HugoDF/mongo-query-clause-modification We’ll ...
#node #Express #javascriptRead and parse POST/PATCH/PUT request JSON or form body with Express and no dependenciesWhen asked to handle data in a request body, developers who have used Express (the “Fast, unopinionated, minimalist web framework for Node.js”) before, reach for the body-parser library. What they might not know is that body-parser is a dependency of Express and its main JSON par ...
#node #javascript #Sequelize #productivityUsing ES6 classes for Sequelize 4 or 5 modelsThe ES2015 or ES6 specification introduced class to JavaScript. Libraries like React went from React.createClass to class MyComponent extends React.Component, ie went from rolling their own constructor to leveraging a language built-in to convey the programmer’s intent. For a Nod ...
#testing #jest #node #javascript #jestJest assert over single or specific argument/parameters with .toHaveBeenCalledWith and expect.anything()With Jest it’s possible to assert of single or specific arguments/parameters of a mock function call with .toHaveBeenCalled/.toBeCalled and expect.anything(). The full example repository is at github.com/HugoDF/jest-specific-argument-assert, more specifically lines 17-66 i ...
#express #docker #javascript #nodeAn enterprise-style Node.js REST API setup with Docker Compose, Express and PostgresThe why and how of enterprise-style Node.js application. A setup that’s easy to test and extend using battle-hardened technologies like Express.js, Postgres and Docker Compose to run locally. Dive into the code on GitHub directly: github.com/HugoDF/express-postgres-starter. ...
#deployment #netlify #cdn #metaEnable CDN (Cloudflare) caching for your Netlify siteThis post goes through how to reduce the amount of static assets served through Netlify by leveraging a CDN (Content Delivery Network) like Cloudflare. This will reduce your Netlify bandwidth usage for cacheable assets. It will also mean that you’re following industry-accepted be ...