Skip to main content

2 posts tagged with "nodejs"

View All Tags

· 6 min read
Mitchell Mudd

Explore how to handle multipart forms in nodeJS with busboy!

In this post, we'll be exploring how to parse multipart form data in Node.js. We'll be using the busboy module to help us accomplish this! We'll also be using the file system module to save the file to your device.

Getting Started

In an empty folder run the following command to create a package.json file

npm init -y

Then run the following command to initialize a git repository

git init

Create a .gitignore file and add the following line to it. This will tell git to ignore the node_modules folder when we push it to our repository.

node_modules

Finally, run the following command to install the busboy module which we'll be using to parse the form data

npm install busboy

Inside the folder you created, create a file called index.js and one called index.html and open them in your favorite text editor...

· 3 min read
Mitchell Mudd

Thumbnail Advent of code is a coding challenge that happens every year in December. This is my first year taking part and I found it a bit clunky to copy and paste the input into a string within my JavaScript file.

The solution: use the Node File System module in synchronous mode 🙂 Using fs.readFileSync may not be best practice on normal project (you’re blocking the program from moving until the file is processed), but for advent of code it’s really nice to simply get your input.