Skip to content

A simple boilerplate to create REST apps with koa2, babel and webpack

Notifications You must be signed in to change notification settings

romualdr/koa-babel-webpack-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-babel-webpack-boilerplate

A simple boilerplate to create REST apps with

  • koa@next (currently 2.0.0-alpha.3)
  • babel (for async, await and stage-2 support)
  • webpack

How to use

Boilerplate is packed with koa-router@next in order to have a routing system.

Install development dependencies

npm i

Create a route

router.get('/:id', async (ctx) => {
  ctx.body = await database.get(ctx.params.id);
  // Feel the awesomeness
});

Run development

npm run development

Build

npm run build

Run the built version

node bin/server.bundle.js
// or
npm run run

Distribute and run the built file

npm i --production // to avoid dev dependencies
npm run run

### Exceptions

This boilerplate contains a simple HTTP exception system in order to demonstrate how to deal with exceptions in koa. See exceptions.js.


Why webpack/babel ?

babel-node is not recommended for production. While node doesn't support natively async/await, we need to transpile the code with babel. Webpack is not necessary in this boilerplate but having the server built in a single file is pretty awesome though.

License

MIT

About

A simple boilerplate to create REST apps with koa2, babel and webpack

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published