This is an example project for an Express server implemented in typescript.
start
: builds the server and then starts it.start:watch
: starts the server and continuously rebuilds it if any typescript file changes; to be used in development.test
: executes the tests.test:watch
: starts the test execution and continuously restarts tests if any typescript file changes; to be used in development.clean
: clean out all *.js and *.map.js (resulting from Typescript compilation) files from ./src and ./test.
The application is built on a structure of routers and sub-routers
corresponding to the resource structure of the REST API, which has its root in api/
. Each
sub-router is placed in its own module directory:
src/api
: provides the express root application resource forapi/...
src/api/v1-resource
: provides the implementation of the sub-router for/api/v1/...
src/api/v1-resource/jobs-resource
: provides the implementation of the sub-router forapi/v1/jobs/...
. This resource provides an example of posting jobs into a queue (based on Kue) which executes the jobs in the background.src/api/v1-resource/users-resource
: provides the implementation of the sub-router forapi/v1/users/...
. The resource mimics a DB server which just returns a list of user names.
Each of the module directories has a corresponding BDD style test specification
in ./test
. These tests use mocha as test runner and
chai for assertions.
The Kue component is based on Redis. In order to run the server a Redis instance must be created. A suggestion is to use the official Redis docker image.