Every company has, usually, a single service to handle images that allows people to get easy access to them. Microservices aren’t a new thing, but now it’s an hot topic (although I won’t discuss about the advantages of using microservices in this post, I think this is a must read.) – and that’s why I have decided to create a microservice to store images into the file system, and called it ImaUp.
This service is a simple API that supports image upload and detects duplicated images by calculating the image hash, and saves them into the file system.
Here’s a set of tools that I have used to make my job easier:
Gulp for running my tasks, it’s my favourite one and I won’t argue the pro/cons against grunt or other.
Babel because it’s the most mature transpiler and supports almost 100% of ES6.
Standard it’s very useful because forces all team members to use the same code style. Some people think that code style is personal but I disagree: standardize it turns the code more readable and makes life easier for the next guy who will work on it.
For me, HapiJs is the best framework to create Api’s in node. Why? Because is easy to learn, separates the logic from the framework, it’s easy to test using Lab and it’s plugable! There are a lot of plugins that can make our life easier: swagger, authentication, logging, etc…
I chose Mongoose to manage the operations to MongoDb, because it’s easy, stable and supports native promises.
You can check the code on my GitHub