Google phone library web service project

GitHub Repository: webservice-phonelibrary

The first submission for my open source class assignment has been made. The project works, but is far from complete. Looking back at my experience, I’ve learned quite a few things with respect to modules in Node.JS. For example, I’ve never used multer before as I did not need to process file uploads. From this experience, I’ve learned to search and read the API for another github project. Using multer, I was able to read from a file and delete a file (after finishing processing the file).

Since findNumbers() method was not defined from the google library and I was limited in time, I’ve decided to write a quick and dirty regular expression to handle North American phone numbers. This took some time as I needed to refresh my memory from the last time I’ve used regular expressions. On a side note, it is interesting to note that Express JS uses routes regular expression to detect and handle routing.

Some issues I ran into while creating this web service were errors when calling the code in the library. For example, when calling isPossibleNumber(), the error message I got was

a.getNationalNumber() is not a function

It was frustrating to find that there were no other methods I could call that worked, which allowed me to quickly verify if a number is valid or not.

With regards to unit testing, I’ve been using SuperTest for a while, but now I’ve learned how to perform tests with file uploads.

Furthermore, I’ve had for the longest time, a problem with testing the web service was I have two test files, one file tests the root endpoint, the second test file is responsible for testing the parse endpoints. When I execute the test with jest, the test files are ran concurrently using my app.js file. Having app.listen() inside app.js will result in collisions when jest attempts to start two test instances concurrently.

The solution as suggested by Professor Humphrey was to separate the code for starting the server with the app itself. I’ve created server.js which includes the logic to start the server, in app.js, I export the app variable to allow server to take over and start the server instance.

Once I’ve completed coding, I went to put my efforts into crafting my README.md file. I’ve also learned to create new issues on Github to allow others to contribute as well as allow issue tracking for a project.

This has been an interesting experience. I look forward to contributing to other’s projects and fixing their bugs.

One thought on “Google phone library web service project

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s