Express & TypeScript API-Boilerplate
A full-blown Express RESTful API-boilerplate written in TypeScript.
Build with:
Getting started
- Be sure you have Yarn installed globally.
- Clone the repo & run
yarn
from the project root
Configuration
Middleware-functions can be addedd though App.use(middleWareFunction())
. Configs can be array of middlewares or a single middleware-function where the second argument is a boolean which states if this middleware should be enabled.
See index.ts as example.
Routing
Each route added with App.route()
has to extend the abstract BaseRoute
-class or CrudRoute
-class with overridden members:
BaseRoute
method: string (http-verb)
endpoint: string (the actual route)
middleware
: array (optional middleware-functions for this specific route)respond(): Response
CrudRoute
endpoint: string (the actual route)
middleware
: array (optional middleware-functions for this specific route)[HTTP-VERB](): Response
: HTTP-verbs which this route supports. For example, if there's no PUT-method defined & PUT-request is coming to this route => an Exception is thrown.
See modules as example.
Available commands:
yarn start
: Executes Nodemon & refreshes app on file-changeyarn lint
: Executes TSLint & TypeScripttsc
(typecheck)yarn build
Builds app as regular Javascript (es2015) to/dist
Todo:
- Route-middleware
- Resourseful routing
- Unit tests
- ...?