Skip to content

Latest commit

 

History

History
107 lines (95 loc) · 2.11 KB

README.md

File metadata and controls

107 lines (95 loc) · 2.11 KB

Syndicate::Users Microservice

This microservice provides authentication, authorization, and user data for internal and external api reference.

Installation

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

Usage

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"]

Structure

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

API Reference

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
  }
}

Contributing

Pull requests are always welcome. Please open an issue before making any drastic changes.

Licence

MPL-2.0