Articles
NodeJS modules
A JavaScript file can be imported as a module into another file using the <code>require</code> command. For example, he file myPackage.js can be imported as so:
Puppeteer setup for NodeJS
Puppeteer is a headless browser with which NodeJS can interact to automate web pages manipulation.
Express authorization middleware
Many applications require some form of authorization mechanism to prevent users from accessing restricted content. Authenticated users are commonly in possession of a cookie containing identification data. With the authentication microservice that I designed, this cookie contains a JWT that contains the user's username. This JWT is sent in the authorization header of HTTP requests. Thus, authorization can be performed easily within each application by simply decoding the JWT. To do so, I designed this simple middleware for ExpressJS.
NodeJS app dockerization
NodeJS apps can be containerized using the <code>docker build</code> command. This article is based on <a href="https://nodejs.org/de/docs/guides/nodejs-docker-webapp/" rel="noopener noreferrer nofollow">this guide</a>.
connect-history-api-fallback ignore certain routes
For example, if the route /file needs to be handled by express and not the single page application:
Publish a module to NPM
This article is based on <a href="https://www.freecodecamp.org/news/how-to-make-a-beautiful-tiny-npm-package-and-publish-it-2881d4307f78/" rel="noopener noreferrer nofollow">this publiation</a>.
Testing in NodeJS with Mocha
Mocha is a popular testing framework for NodeJS. it can be installed using npm:
Mongoose bulkWrite upsert
Here is a code snippet for a bulk update with upsert using Mongoose:
LINE Bot
<p>LINE offers an API to developers looking into creating chat bots. I created my own so that I could send myself notifications.</p>
Node.js DevOps example
In this article, we’ll build a simple Node.js application that uses Express to respond to HTTP requests. In order to deploy this application to production, we’ll also configure a GitLab CI/CD pipeline so as to dockerize it and deploy its container to a Kubernetes cluster.