Edge node-express api using Docker, Typescript, codeship & mongoose

Aurélien Hervé
HackerNoon.com
3 min readSep 14, 2016

--

I've recently been busy refactoring our api build for Hunteed and the result looks like it could be open-sourced.

So Here it is, an edge-build for developing a node-express api using modern tools such as Docker, @typescriptlang, @codeship, mocha

Some of the cool features it provides :

  • Following the spirit of this post : we have a one-click install of the whole environment. Don't worry about mongodb, npm, or anything else, just run docker-compose up and you're ready to work.
  • Whole project uses typescript. And typescript validation is just awesome. Try adding some typos to your code and see the console warn you instantly:
typo: public exists but not puublic
Typescript knows that View.count() will return a number. You can't expect the result to be a string.

In my opinion, there is no coming back to javascript once you tried typescript. It just makes development & maintenance several times faster, while ensuring preventing MANY runtime bugs.

  • No messing with babel anymore. Neither to run mocha, your local or remote server. Typescript compiles everything into good old es2015 code that you can use about everywhere
  • No more callback hell :
Await/Async usage
Promise style usage
  • mocha Unit tests are launched at each change. They are written in the cool ES7-like syntax, but are run against transpiled js code. I particularly like this await syntax:
  • Continuous testing: Easy as pie : we use docker to build our app and run a local server. Codeship can run the exact same container to run the tests so there is no discrepancy between the different environments. Almost no additional work to do, and you can browse the result anytime you like:

Hope you like it :)

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMI family. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!

--

--