Node.js — Get a File’s Created Date

The file system module in Node.js provides all file-related functions. Access file details with the help of a so called “stats” instance. {{outline}} Created Date of a File Use the fs module in Node.js to retrieve a stats instance of a given file including meta data like the …

Continue Reading

Get Number of Seconds Since Epoch in JavaScript

Working with dates and times in JavaScript can be cumbersome. The Date class provides methods to interact with dates and times. Usually, you need to put more effort into calculating the value that you’re interested in. In various situations, it’s favorable to calculate the seconds since epoch in …

Continue Reading

Node.js — Write a JSON Object to a File

When working on a new feature or app idea, storing data on the file system can be a good solution. You can skip the database setup and save JSON to a file instead. {{outline}} Write JSON to File JavaScript comes with the JSON class that lets you serialize an object …

Continue Reading

learn hapi — JWT Logout (Part 1/2)

Authenticating users in web applications or APIs has different approaches. Invalidating a user’s server-side session or an authentication-related cookie is in your full control. With JSON web tokens (JWTs), you need to extend your platform with a custom logout handling ensuring to invalidate an active JWT. Because there’s …

Continue Reading

Node.js — Filter Data in Streams

Using streams in Node.js is a powerful mechanism to process data. Especially when working with large data sets where you might want to filter chunks that don’t match a given criteria. {{outline}} Example: Loading Lines From File to Database Imagine the following example: you want to load a …

Continue Reading
Page 1 of 31

Explore the Library

Find interesting tutorials and solutions for your problems.