Document Management System is an application that helps users manage their documents. A User can upload a document, edit and share with other users.The application permits users to work collaboratively on documents.
This application is created using Nodejs environment. It implements Express as the routing framework and Mongoose, an object modeling package, to interact with MongoDB.JWT tokens have also been used to authenticate routes.
- Install Nodejs and MongoDB
- Clone this repo or download the zipped file.
- Navigate to the master branch.
- Run
This will install the required dependencies.
npm install
- Run
This will seed the database
npm run seed
- Run
npm test
to run the tests. 7. Run
npm start
Use Postman to consume the API. 8. Well...enjoy.
Create a new user
POST - /api/v1/users
Post data
{
username: 'username',
email: 'example@host.com'
lastname: 'lastname',
firstname: 'firstname',
password: 'password',
role: 'Administrator' // Role has to be created before assignment.
}
Login a user
POST - /api/v1/users
Post data
{
username: 'username',
password: 'password'
}
Create a new document
Documnent is created by an existing and authenticated user.
POST - /api/v1/documents
Post data
{
title: 'Documnent title',
content: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
}
**Create a new role
Role is created by an Authorized and Authenticated user.
POST - /api/v1/role
Post data
{
role: 'Test'
}
API endpoints currently supported.
Users
Request type | Endpoint | Action |
---|---|---|
POST | /api/v1/users | Create a new user |
GET | /api/v1/users | Get all users |
GET | /api/v1/users:id | Get a user |
PUT | /api/v1/users/:id | Update user information |
DELETE | /api/v1/users/:id | Remove a user from database |
Documents
Request type | Endpoint | Action |
---|---|---|
POST | /api/v1/documents | Create a new document |
GET | /api/v1/documents | Retrieve all documents |
GET | /api/v1/documents/:id | Retrieve a specific document |
GET | /api/v1/users/:id/documents | Retrieve all documents created by a user |
GET | /api/v1/documents/?role=Andela | Retrieve all documents that contains 'Andela' |
GET | /api/v1/documents/q=Andela&limit=10 | Retrieve documents that contains 'Andela' in group of tens |
GET | /api/v1/documents/?q=Andela&role=Test | Retrieve documents that contains 'Andela' with Test access |
PUT | /api/v1/documents/:id | Update a specific document |
DELETE | /api/v1/documents/:id | Remove a specific document from storage |
Roles
Request type | Endpoint | Action |
---|---|---|
POST | /api/v1/role | Create a new role |
GET | /api/v1/role | Retrieve all roles |
PUT | /api/v1/role/:id | Edit a role |
GET | /api/v1/role/:id | Retrieve a role |
DELETE | /api/v1/role/:id | Delete a role |
This application has been tested using chai, which is a Super-agent driven library for testing Node.js HTTP servers using a fluent API and Mocha, which is a feature-rich JavaScript test framework running on Node.js and the browser, making asynchronous testing simple and fun.
Thank You.