This is a very simple opinionated seed/skeleton project to demo how to build an API and bundle it into a single file, to run it locally or host it in a webtask.io
container.
npm install -g gulp
npm install -g wt-cli
npm install
wt init
=> then follow instructionswt profile get default
=> copy the token
- open
./config/webtask.config.js
and configure thewebtaskToken
property with your token
gulp run
orgulp debug
gulp deployWebtask
This boilerplate uses webpack
for bundling the API and gulp
for build/deploy automation.
API source code was written in ES6
, it uses Express.js
for the web stack and MongoDb
as repository.
This API tries to implement a simplified version of the REST design pattern, following the guidelines described by DDD. The communication flow between different layers of the API is:
{Http requests} => [Controller] => [Service] => [Repository] => {database}
- Controller: handles http methods dispatching operations to the service layer and it does the translation between requests/responses and domain model entities.
- Service: implements the business logic of the domain model.
- Repository: handles the persistency of the domain model.
- Edit your configuration files for setting up secrets and parameters.
- Create a route installers for your API and define all routes you want to implement.
- Create a controller for handling your routes.
- Create a service for implementing your business logic.
- Create a repository for storing the domain model.
- TBD: Add unit tests for your controllers and services.
- TBD: Add integration tests for your repositories.
- Run/debug your api locally.
- Deploy your api to
webtask.io
.
- Add tests and a gulp task for running them and a configuration file for tests
- Add an auto reload task for local development
- Add an auto re-deploy task and stream logs to the console for 100% remote development
- Validate required modules against
https://tehsis.github.io/webtaskio-canirequire/
as a part of the build - Refactor the
gulpfile
into different plugins for future publishing