Minh Huy Nguyen - OSD600

GitHub RSS

Doing the first project for OSD600

Published: | Updated:

The first project was a CLI program which check all legit links from a file and return statusCode with colors. You can have a look at my project here

I used colors and request for this project. Which can be install by using npm i --save colors request

The method to program this was reading arguments from user and do some specific tasks based on these arguments. First I used Regex and Split to extract valid links from the input file, then use ‘request’ to get statusCode and print the output with colors and statusCode. I also used ‘timeout’ for HTTP requests, but it seemed I got so many wrong results because links required longer to get response. It seemed smoother, but I think accuracy is more important.

How to run? Whether you familiar with NodeJs or not. First you will need to clone my project by using: git clone https://github.com/VietnameZe/insane-cli.git

Then install dependencies: npm i –save colors request

Next step, run command npm link so you can run program globally using syntax: insane-cli <args>.

For argument options, you can just pass the file path for even a URL with option -url (insane-cli -url https://www.google.com), in this case the program will fetch the URL’s body content, extract and validate all contained links from it.

The challenge in this project wasn’t how to make it work, but to optimize it to run faster. When I tried to make it faster, it returned too many wrong answers, but when it runs with more accuracy, the program just take a half minutes to be done, this is the problem that I need to solve in upcoming labs.