Takeoff V2 — Making rapid development even easier with TypeScript and Docker

Last year I released Takeoff, a cli tool (github | website) that provided a way to create simplified docker-compose environments that provided a batteries included API server using Node and Hapi, a React frontend, a Postgres DB and a Nginx ingress server .

As usual with side projects, they get occasionally pushed to the side but recently I wanted to revisit the project with some clear goals and get version 2 out.

It’s really easy to get started with Takeoff:

npm install -g @takeoff/takeoff
takeoff init cd takeoff
takeoff start

The above commands create a new folder called takeoff where it creates two folders, one for blueprints and one for projects. There are some default values to get you started, but you can find all the commands in the CLI documentation. The default project installs all the local dependencies and then builds the docker images. By starting the project you bring up a docker-compose file that links the projects together and is available right away on http://localhost .

Less Turbulence

One of the main issues I had was the configuration file I has created was hacky and wasn’t easy to maintain. I had seen Maid, a task runner based on Markdown and was inspired to implement a simple task runner and a new takeoff.md file to control setting up projects. I’ve re-implemented it in TypeScript and intend to expand this to provide configuration flows for different OS and environments.

An example of a takeoff.md file. Each command is run in the order defined by tasks.

I also wanted to make the CLI more configurable by adding support for custom commands, and adding a new .takeoffrc file (which is currently empty) to make it easy to give full control.

Typescript all the way down…

The biggest change in this release is the entire project is now written in Typescript, both within the CLI and within the default blueprint provided.

The CLI changes allowed me to squash many bugs, and reason more with the data that flows through the lifecycle of a CLI command.

Commands are now broken down into a new TakeoffCommand Type that provides a consistent contract, and they receive helper functions injected that provide a clean way to print and exit command. Into it is provided the TakeoffCmdParameters object.

Here is an example of one of the commands:

There is documentation provided on how to easily add your own project-level commands, and really they can be anything — there is a shell helper for running commands, but you can also import and use any library you wish.

You also get passed arguments and options and two helpers to print messages on the screen. It’s easy to make sure your command exits with the right code if it passes or fails.

New Blueprint

The new default blueprint has two major changes:

  • The Frontend app is now an Angular application
  • The database has switched from MongoDB from Postgres

In the past year, I have been mostly working with Angular and the React application had fallen way behind in versions and code style. The new Angular app itself isn’t actually finished, however it does come ready to serve with Authentication and JWT token support. I will be working on this app over the coming months to improve it, but it still fulfills 90% of the goals of the React app. I’m trying to avoid using stores at the moment, but I am looking to have best practices with Observables and side-effects.

The second big change was going from Postgres to MongoDB. As Takeoff is all about rapid development, and not scale, I felt it was easier to support going forward using Mongoose to provide the database abstraction and ORM. The change is fairly recent so it hasn’t been fully documented, but looking at the code should help — but I also want to make it easier to add models in a more configurable way.

The backend application has also been entirely re-written in Typescript, however I’ve had some issues with Hapi and you may find some (foo as any).bar code in there. The plan is so make this much more type compliant. Also a future feature will be to add a GraphQL endpoint

A New Start

This release is just the start of a lot of new features for Takeoff. My goal is to make life easier for developers of all skill levels and in a way that provides a consistent experience though the blueprint feature. Of course this app is full of my own opinions, and I’d love to hear about any ideas or suggestions to make it more useful.

Digital Technology Leader @ IKEA — Digital Acceleration and Data Transformation