paint-brush
Edge node-express api using Docker, Typescript, codeship & mongooseby@aherve
1,176 reads
1,176 reads

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

by Aurélien HervéSeptember 14th, 2016
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

I've recently been busy refactoring our api build for <a href="https://medium.com/@hunteed" data-anchor-type="2" data-user-id="4fb3c47e7f1c" data-action-value="4fb3c47e7f1c" data-action="show-user-card" data-action-type="hover" target="_blank">Hunteed</a> and the result looks like it could be open-sourced.

Company Mentioned

Mention Thumbnail
featured image - Edge node-express api using Docker, Typescript, codeship & mongoose
Aurélien Hervé HackerNoon profile picture

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


aherve/typescript-express-docker_typescript-express-docker - Dockerized node-express application, written in typescript_github.com

git clone https://github.com/aherve/typescript-express-docker.git

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 :)