Giter Club home page Giter Club logo

docqeep's Introduction

Build Status Coverage Status Code Climate

Document Managemet System

Document Management System API contains several APIs that allows users to create, edit, retrieve and delete documents. It also offers a way to ensure that only authroized users can perform certain operations.

Development

The application was developed with NodeJs while using Express for routing. The Postgres database was used with sequelize as the ORM

Installation

  1. Ensure you have NodeJs and postgres installed
  2. Clone the repository git clone [email protected]:andela-foladeji/dms-api.git
  3. Change your directory cd dms-api
  4. Install all dependencies npm install
  5. Run tests npm test
  6. Start the app npm start and use postman to consume the API

API ENDPOINTS

Users

Request type Endpoint Action
POST /users Create a new user
GET /users Get all users
GET /users/:id Get details of a specific user
PUT /users/:id Edit user details
DELETE /users/:id Remove a user from storage
POST /users/login To log a user in

Roles

Request type Endpoint Action
POST /role Create a new role
GET /role Get all created roles

Documents

Request type Endpoint Action
POST /documents Create a new document
GET /documents Retrieve all documents
GET /documents/:id Retrieve a specific document
GET /users/:id/documents Retrieve all documents created by a user
GET /documents?page=1&limit=10 Retrieve maximum of first 10 documents
PUT /documents/:id Update a specific document
DELETE /documents/:id Remove a specific document from storage

Users

Create Users

To create a new user, make a POST request to /users

Request

{
  "firstName": "Jane",
  "lastName": "Doe",
  "username": "janedoe",
  "email": "[email protected]",
  "password": "secretkey",
  "roleId": "1"
}

Response

json
{
  "done": true,
  "user": {
    "id": 1
      "firstName": "Jane",
      "lastName": "Doe",
      "username": "janedoe",
      "email": "[email protected]",
      "password": "dskjslk894u8hdk993289389dkndnjeiu34348fn",
      "roleId": "1",
      "createdAt": "2016-12-06T09:25:29.316Z",
      "updatedAt": "2016-12-06T09:25:29.316Z"
  },
  token: "d98whIHSKJHAKdskljEEWRjsdodsjci8943dskljEEWRjsdodsjci8943u9ru348jsdnxssSJoihs98r32u983yd98whIHSKJHAKdskljEEWRjsdodsjci8943u9ru348jsdnxssSJoihs98r32u983yd98whIHSKJHAK"
}

Get Users

Fetches all users' details,

Request

  • Endpoint: GET: /users
  • Requires Authorization header to be set

Response

  [
    {
      "id": "1",
      "firstName": "Jane",
      "lastName": "Doe",
      "username": "janedoe",
      "email": "[email protected]",
      "roleId": "1",
      "createdAt": "2016-12-06T09:25:29.316Z",
      "updatedAt": "2016-12-06T09:25:29.316Z"
    }, {
      "id": "2",
      "firstName": "Dead",
      "lastName": "Pool",
      "username": "deadpool",
      "email": "[email protected]",
      "roleId": "2",
      "createdAt": "2016-12-06T09:25:29.316Z",
      "updatedAt": "2016-12-06T09:25:29.316Z"
    }
  ]

Get A User

Request

  • Endpoint: GET: /users/:id
  • Requires Authorization header to be set

Response

  {
    "id": "1",
    "firstName": "Jane",
    "lastName": "Doe",
    "username": "janedoe",
    "email": "[email protected]",
    "roleId": "1",
    "createdAt": "2016-12-06T09:25:29.316Z",
    "updatedAt": "2016-12-06T09:25:29.316Z"
  }

Update user

Request

  • Enpoint: PUT: /users/:id
  • Requires Authorization header to be set
{
  "firstName": "Doctor",
  "lastName": "Strange",
  "username": "docstrange",
  "email": "[email protected]",
  "password": "astroprojection",
  "roleId": "1"
}

Response

Body (application/json)

  {
    "done": true,
    "user": {
      "firstName": "Doctor",
      "lastName": "Strange",
      "username": "docstrange",
      "email": "[email protected]",
      "roleId": "1"
    }
  }

Delete user

Request

  • Enpoint: DELETE: /users/:id
  • Requires Authorization header to be set

Response

Body (application/json)

  {
    "done": true
  }

Login

Request

  • Endpoint: POST: /users/login
  • Body (application/json)
{
  "username": "docstrange",
  "password": "astroprojection"
}

Response

Body (application/json)

{
  "done": true,
  "user": {
    "firstName": "Doctor",
    "lastName": "Strange",
    "username": "docstrange",
    "email": "[email protected]",
    "roleId": "1"
  },
  token: "sdfeofJOIFiflfjKJ48lj8949fjeofJOIFiflffjKJ4848wjKJ484894NNsdfeofJOIFifUNnowIFiflfjKJ4848wesflfjKJ4848"
}

ROLES

Create Role

Request

  • Endpoint POST /role
  • Requires Authorization header to be set Body (application/json)
{
  "title": "Admin"
}

Response

Body (application/json)

{
  "done": true
}

Get Roles

Request

  • Endpoint GET /role
  • Requires Authorization header to be set

Response

{
  "roles": [
    {
      "id": 1,
      "title": "Admin",
      "createdAt": "2016-12-06T09:25:29.316Z",
      "updatedAt": "2016-12-06T09:25:29.316Z"
    },
    {
      "id": 1,
      "title": "Regular",
      "createdAt": "2016-13-06T09:25:29.316Z",
      "updatedAt": "2016-13-06T09:25:29.316Z"
    }
  ]
}

DOCUMENTS

Create Document

Request

  • Endpoint POST /documents
  • Requires Authorization header to be set
{
  "title": "Marvel",
  "content": "Diary of a movie addict",
  "access": "role"
}

Response

  • Body (application/json)
{
  "done": true,
  "doc": {
    "title": "Marvel",
    "content": "Diary of a movie addict",
    "access": "role",
    "createdAt": "2016-13-06T09:25:29.316Z",
    "updatedAt": "2016-13-06T09:25:29.316Z"
  }
}

Get Document

Request

  • Endpoint GET /documents
  • Optional queries page (for the page number) && limit (number of documents per page)
  • Requires Authorization header to be set

Response

[
  {
    "title": "Marvel",
    "content": "Diary of a movie addict",
    "access": "role",
    "ownerId": "1",
    "createdAt": "2016-13-06T09:25:29.316Z",
    "updatedAt": "2016-13-06T09:25:29.316Z"
  },
  {
    "title": "The accountant",
    "content": "J.K simmons was in the movie as well as Ben Affleck, one of my fav",
    "access": "private",
    "ownerId": "2",
    "createdAt": "2016-13-06T09:25:29.316Z",
    "updatedAt": "2016-13-06T09:25:29.316Z"
  }
]

Get A Document

Request

  • Endpoint GET /documents/:id where id is the id of the document
  • Requires Authorization header to be set
Response
{
  "title": "Marvel",
  "content": "Diary of a movie addict",
  "access": "role",
  "ownerId": "1",
  "createdAt": "2016-13-06T09:25:29.316Z",
  "updatedAt": "2016-13-06T09:25:29.316Z"
}

Get Documents By User

Request

  • Endpoint GET /users/:id/documents/ id is the id of the user
  • Requires Authorization header to be set

Response

[
  {
    "title": "The accountant",
    "content": "J.K simmons was in the movie as well as Ben Affleck, one of my fav",
    "access": "private",
    "ownerId": "1",
    "createdAt": "2016-13-06T09:25:29.316Z",
    "updatedAt": "2016-13-06T09:25:29.316Z"
  }
]

Update Document

Request

  • Endpoint PUT /documents/:id id is the id of the document
  • Requires Authorization header to be set
{
  "title": "The accountant",
  "content": "J.K simmons was in the movie as well as Ben Affleck, one of my fav",
  "access": "private",
  "ownerId": "2",
}

Delete Document

Request

  • Endpoint DELETE /documents/:idid of the document
  • Requires Authorization header to be set

Response

{
  "done": true
}

docqeep's People

Contributors

femioladeji avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.