generator-astro-nodejs
v1.4.2
Published
Yeoman generator for NodeJS-based microservice
Maintainers
Readme
Astro Generator NodeJS
Yeoman generator for building RESTful APIs and microservices using Node.js, ExpressJS and Docker support, and fullstack service with ReactJS, Redux, and Redux Observable.
Server Features
- No transpilers, just vanilla javascript
- ES2017 latest features like Async/Await
- CORS enabled
- Uses yarn
- Express
- Consistent coding styles with editorconfig
- Docker support
- Uses helmet to set some HTTP headers for security
- Load environment variables from .env files with dotenv
- Request validation with joi
- Gzip compression with compression
- Linting with eslint with eslint-config-astro
- Tests with jest along with coverage
- Git hooks with husky
- Logging with winston, and winston-cloudwatch for production log stream
- API documentation geratorion with apidoc
- Monitoring with pm2
- Startup boot tasks that can be used for data migrations or pre startup task runner.
- ORM using Sequelize (optional) sequelize with docker-compose migrations
- HTTP using axios with retry axios
Requirements
Getting Started
Install:
npm install -g yo generator-astro-nodejsGenerate a new project:
yo astro-nodejsServer Side Generator
Generate a new API:
yo astro:apiGenerate a new middleware:
yo astro:middlewareGenerate a new service:
yo astro:serviceGenerate a new utility:
yo astro:utilGenerate a new boot task:
yo astro:bootSet environment variables:
cp .env.example .envRunning Locally
yarn devRunning in Production
yarn startLint
# lint code with ESLint
yarn lint
# try to fix ESLint errors
yarn lint:fix
# lint and watch for changes
yarn lint:watchSequelize Migrations (optional)
yarn db:migrate
# to undo the migration
yarn db:migrate:undoTest
# run all tests with Jest with coverage
yarn test
# run unit tests
yarn test:unit
# run integration tests
yarn test:integration
# run all tests and watch for changes
yarn test:watchValidate
# run lint and tests
yarn validateLogs
# show logs in production
pm2 logsDocumentation
# generate and open api documentation
yarn docsDocker
# run container locally
yarn docker:dev
or
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
# run container in production
yarn docker:prod
or
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
# run tests
yarn docker:test
or
docker-compose -f docker-compose.yml -f docker-compose.test.yml upCredit
This project is forked from Suhendra Ahmad
