nicholasf / fibonacci-express-typescript

Small HTTP service exercise with typescript, node, docker etc to produce a server that can return Fib numbers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Background

This a mini project so I can just revise using Typescript with Node, along with a configuration I can polish. It's a coding exercise I used to set for applicants interviewing for various teams in various companies. It's an implementation of the Fibonacci sequence, taking a position number and returning the corresponding Fibonacci number.

The exercise exposes:

  • basic coding ability via recursion
  • how to structure a RESTful web service
  • how to test the service.

I've found it helpful as a revision topic. Most of what I have to revise is not how to program generally but the various config surrounding a program's business logic.

Install

I wrote this using node v12.19.0. Any recent version of Node should work.

Then ...

npm install
make

Example

> curl locahost:3000/11
{"position":11,"number":89}%

Docker

Alternatively, you can just run

make docker

Then issue curl commands against port 3000 locally.

You will have to docker ps and run docker stop on the corresponding container to shut it down.

E.g.

♪  fibonacci-express-typescript git:(dockerise-it) ✗ docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED          STATUS          PORTS                    NAMES
9356b2146637   nicholasf/fib-ts-fibonacci   "node ./dist/server.…"   23 seconds ago   Up 22 seconds   0.0.0.0:3000->3000/tcp   busy_bartik
♪  fibonacci-express-typescript git:(dockerise-it) ✗ docker stop busy_bartik
busy_bartik

About

Small HTTP service exercise with typescript, node, docker etc to produce a server that can return Fib numbers


Languages

Language:TypeScript 80.5%Language:JavaScript 10.8%Language:Makefile 4.9%Language:Dockerfile 3.7%