Boilerplate/Generator/Starter Project for building RESTful APIs and microservices using Node.js, Express and MongoDB
- No transpilers, just vanilla javascript
- ES2017 latest features like Async/Await
- CORS enabled
- Uses yarn
- Express + MongoDB (Mongoose)
- 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
- Tests with mocha, chai and sinon
- Code coverage with istanbul and coveralls
- Git hooks with husky
- Logging with morgan
- Authentication and Authorization with passport
- API documentation generation with apidoc
- Continuous integration support with travisCI
- Monitoring with pm2
- Node v7.6+ or Docker
- Yarn
git clone --depth 1 https://github.com/danielfsousa/express-rest-es2017-boilerplate
cd express-rest-es2017-boilerplate
rm -rf .git
yarn
cp .env.example .env
yarn dev
yarn start
# lint code with ESLint
yarn lint
# try to fix ESLint errors
yarn lint:fix
# lint and watch for changes
yarn lint:watch
# run all tests with Mocha
yarn test
# run unit tests
yarn test:unit
# run integration tests
yarn test:integration
# run all tests and watch for changes
yarn test:watch
# open nyc test coverage reports
yarn coverage
# run lint and tests
yarn validate
# show logs in production
pm2 logs
# generate and open api documentation
yarn docs
# run container locally
yarn docker:dev
# run container in production
yarn docker:prod
# run tests
yarn docker:test
Set your server ip:
DEPLOY_SERVER=127.0.0.1
Replace my Docker username with yours:
nano deploy.sh
Run deploy script:
yarn deploy
docker-compose down docker-compose up
Nếu dùng docker thì mongoURI phải đổi thành MONGO_URI=mongodb://mongodb:27017/tdnodejs
https://sequelize.org/master/manual/model-basics.html
Ha Tinh 10.112.42.50 1455 chat/Tandan@123
node_modules\jsonwebtoken\verify.js
comment dong 147
if (typeof payload.exp !== 'undefined' && !options.ignoreExpiration) { if (typeof payload.exp !== 'number') { return done(new JsonWebTokenError('invalid exp value')); } if (clockTimestamp >= payload.exp + (options.clockTolerance || 0)) { return done(new TokenExpiredError('jwt expired', new Date(payload.exp _ 1000))); } }