This microservice provides authentication, authorization, and user data for internal and external api reference.
Run the following commands in a unix environment (or whatever the Windows equivalent is)
git clone https://github.com/bradenn/syndicate-user.git
cd syndicate-user
npm install
Given the nature of microservices, running the server outside of a docker container isn't recommended.
Here is a basic Dockerfile if you are not familiar with Node's integration with Docker.
FROM node:12
COPY . .
RUN npm install
CMD ["node", "index.js"]
src
├── config
│ └── index.js
├── index.js
├── loaders
│ ├── express.js
│ ├── index.js
│ └── mongoose.js
├── middleware
│ ├── authorization.js
│ └── index.js
├── models
│ └── users.js
├── routes
│ ├── auth.js
│ ├── index.js
│ └── users.js
├── services
│ ├── index.js
│ └── users.js
└── validators
├── index.js
└── users.js
Here are some basic requests to get you on the right path...
Get user by ID
POST localhost/api/v1/users/5f3b1951e0a3cd3f4974d977 Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVC...
{
"success": true,
"user": {
"username": "octocat",
"email": "octocat@github.com",
"firstname": "John",
"lastname": "Smith"
}
}
Getting a token
POST localhost/api/v1/auth
{
"username": "username",
"password": "password"
}
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVC..."
}
Standard Error
POST localhost/api/v1/users
{
"success": false,
"error": {
"message": "Invalid authentication token",
"status": 401
}
}
Pull requests are always welcome. Please open an issue before making any drastic changes.