Boilerplate for building REST APIs with ES6 and Express with JWT authentication. It is based on the great boilerplate express-es6-rest-api by Jason Miller
- ES6 support via babel
- REST resources as middleware via resource-router-middleware
- CORS support via cors
- Body Parsing via body-parser
- JWT authentication via passport and passport-jwt
- Password hashing and salting via bcrypt
Tip: If you are using Mongoose, you can automatically expose your Models as REST resources using restful-mongoose.
# clone it
git clone https://github.com/damianmarek/express-es6-rest-api-auth.git
cd express-es6-rest-api-auth
# Make it your own
rm -rf .git && git init && npm init
# Install dependencies
npm install
Make .env
file to store secrets
JWT_SECRET = <YOUR_JWT_SECRET>
MONGO_URL = <YOUR_MONGODB_URL>
# Start development live-reload server
PORT=8080 npm run dev
# Start production server:
PORT=8080 npm start
First you need to ad ENV variables to Dockerfile
ENV JWT_SECRET <YOUR_JWT_SECRET>
ENV MONGO_URL <YOUR_MONGODB_URL>
ENV TEST_MONGO_URL <YOUR_TEST_MONGODB_URL>
cd express-es6-rest-api-auth
Then you can use this commands
# Build your docker
docker build -t es6/api-service .
# ^ ^ ^
# tag tag name Dockerfile location
# run your docker
docker run -p 8080:8080 es6/api-service
# ^ ^
# bind the port container tag
# to your host
# machine port
MIT