Project developed for the MVPmatch process
Clone project to create your project, simply run:
git clone https://github.com/gagocarrilloedgar/vending-api <project-name>
Set the environment variables: (You can see all enviroment key at .env.example)
- NoSQL database: MongoDB object data modeling using Mongoose and hosted on MongoDB Atlas
- Authentication and authorization: using passport and a custom role funciton
- Logging: using winston and morgan
- Testing: unit and integration tests using Jest, mongodb-memory-server and SuperTest
- Error handling: centralized error handling mechanism
- Dependency management: with npm
- Environment variables: using dotenv-safe
- Security: set security HTTP headers using helmet
- Compression: gzip compression with compression
- Git hooks: with husky and lint-staged
- Linting: with ESLint and Prettier (fixing)
- Docs: with APIDoc
- TS: Typescrpit
- Containerization: with Docker to easily deploy to AWS
- Deployment: with AWS Elastic Beanstalk and AWS CodePipeline
Running locally:
npm run dev
building:
npm run build
Running production (build before use):
npm start
Testing:
# run all unit tests
npm test
# run all unit tests in watch mode
npm test:watch
Using the Dockerfile
# Docker start | Start docker
docker build -t [image_name] .
docker run -it -p [PORT]:3000 [image_name]
run from root:
# if not installed
npm install apidoc -g
# create/update the documentation folder
apidoc -i src/ -o public/
or
# npm script
npm run docs
After that if you want to see the documentation simply run:
npm run dev
and go to http://localhost:3000
src\
|--api\
|--config\ # Environment variables and configuration related things
|--middlewares\ # Custom express middlewares
|--models\ # Mongoose models (data layer)
|--routes\ # Routes
|--utils\ # Utility classes and functions
|--app.js # Express app
|--index.js # App entry point
tests\
|--fixtures\
|--integration\
|--utils\
|--...src\
Linting is done using ESLint and Prettier.
In this app, ESLint is configured to follow the Standar JavaScript style guide with some modifications.
To modify the ESLint configuration, update the .eslintrc.json
file. To modify the Prettier configuration, update the .prettierrc.json
file.
To prevent a certain file or directory from being linted, add it to .eslintignore
and .prettierignore
.
Contributions are welcome! Please check out the contributing guide.
You can contact me using:
or: