Create Koa.js API server using the modern ESM Node.js module system + Mongoose
This generator uses ESM modules along with webpack + pkg to build a binary. The .env file used during development will be hardcoded in the resulting binary (however, consider encrypting sensitive data, because simple strings
command can reveale all of your env variables). Also this generator uses the custom Node.js loader functionality to provide custom aliasing like @/lib/email
, which is resolved by webpack during the build.
NOTE: do not forget to add MONGODB_URI variable to .env file when goin prod.
First, install Yeoman and generator-koa-esm-api using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-koa-esm-api
Then generate your new project:
yo koa-esm-api
To create a new route run:
yo koa-esm-api:route name
To create a new model run:
yo koa-esm-api:model name
- Yeoman has a heart of gold.
- Yeoman is a person with feelings and opinions, but is very easy to work with.
- Yeoman can be too opinionated at times but is easily convinced not to be.
- Feel free to learn more about Yeoman.
GPL-3.0 © Seva D.