Skip to content

A simple boilerplate for writing small Koa web services

Notifications You must be signed in to change notification settings

aandrewww/koa2-simple-ws-boiler

Repository files navigation

Koa Boilerplate

👏 A simple boilerplate for writing small Koa web services

Getting Started

$ git clone https://github.com/aandrewww/koa2-simple-ws-boiler your-project-name
$ cd your-project-name
$ rm -rf .git && git init
$ npm install
$ npm start

What's in the package?

  • npm run scripts.
  • axios for Promise based requests.
  • bluebird featured promise library.
  • eslint as JavaScript linter.
  • prettier code formatting, configured to work with eslint out of the box.
  • husky for git hooks.
  • koa-bodyparser for parsing request bodies.
  • koa-helmet adds important security headers.
  • koa-validate validate request params and format request params.
  • koa2-cors CORS middleware for cross-domain requests.
  • koa-respond for helper functions on the context.
  • dotenv for environment variable management.
  • log4js for logging.
  • lodash utility library.
  • mongoose as elegant mongodb object modeling for node.js.
  • yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface.

npm run scripts

There are a few defined run scripts, here's a list of them with a description of what they do. To run them, simply execute npm run <script name> - e.g. npm run lint

  • start: Used for simple start app.
  • test: Runs tests (NOT SUPPORTED).
  • lint: Lints

Environment variables

Rename (or copy and rename) .env.default into .env

cp .env.default .env

The environment variables can be reached via dotenv package.

require('dotenv').config({ path: path.join(__dirname, '/.env') });

Todo...

There're some features (updates) which will be included in this starter in the near future:

  • Add route for '/'.
  • Add directory structure into Readme.
  • Add simple model.
  • Add eslint description
  • Add tests
  • Add coverage for tests
  • Add support clasterization
  • Add koa-compress
  • Add npm run ngrok (?)

Author

License

MIT.

About

A simple boilerplate for writing small Koa web services

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published