Example Auth API with Express.
- Production: https://example-auth-express.azobu.app
- Heroku: https://azobu-example-auth-express.herokuapp.com
- Google App Engine: https://azobu-example-auth-express.REGION.r.appspot.com
- Amazon EBS: https://azobu-example-auth-express.example.com
- REST API
- Express
- Body Parser
- Cookie Parser
- bcrypt
- JWT
- Debug
- Morgan
- Postman
- MongoDB, Mongoose, and mLab
- Later: MySQL, Sequelize, and MySQL instance
- Heroku
- Later: Amazon EBS
- Later: Google App Engine
- Cloudflare
- Uniregistry
- Seed new users
- Register new user
- Name
- Password encrypted using bcrypt
- Login to existing user
- Password
- Authorization token with JWT
- Get all users
- Don't show the password
- Get user by id
- Don't show the password
- Search users by name
- Remove all users
Endpoint | HTTP | Description |
---|---|---|
/ |
GET |
Get index title |
Endpoint | HTTP | Description |
---|---|---|
/auth/register |
POST |
Register new user |
/auth/login |
POST |
Login to existing user |
/auth/logout |
POST |
Logout the logged in user |
/auth/validate |
POST |
Check if user token is valid |
Endpoint | HTTP | Description |
---|---|---|
/users/seed |
POST |
Seed initial users |
/users |
GET |
Get all users |
/users/:id |
GET |
Get user by id |
/users/:id |
PUT |
Update user by id |
/users/:id |
DELETE |
Delete user by id |
/users |
DELETE |
Delete all users |
/users/profile |
GET |
Get authenticated user profile |
/users/search?name= |
GET |
Search user by name |
Run the setup.sh
script first, to copy .env.schema
into .env
.
./setup.sh
Then you fill the variables in .env
file.
Remember to install and make sure MongoDB is running on your machine.
MONGODB_URI=mongodb://localhost:27017
JWT_SECRET=this_is_your_secret
MONGODB_URI=mongodb://urltomongodb.com:27017
JWT_SECRET=this_is_your_other_secret
yarn
yarn dev
yarn start
yarn test
Run Postman collection.
heroku logs --tail -a api-haidar-dev
MIT