Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
3693bd5
set up staging
Jul 8, 2017
aa917cc
chore(eslint):configure-eslint
Jul 8, 2017
9867473
chore(base-application):Set up base application
Jul 8, 2017
5407410
chore(base-application):Set up base application
Jul 9, 2017
04251bd
chore(sequelize): setup sequelize
Jul 9, 2017
9826695
feat(schema): database-schema
Jul 20, 2017
81bcde2
chore(gulp):set-up-gulp
Jul 20, 2017
d1f979c
feat(game screen): redesign game screen
Jul 20, 2017
bdf1b28
chores(hound):integrate-houndci
Jul 20, 2017
7219d50
chore(routes):setup-routes
Jul 20, 2017
857d8a1
fix schema
Jul 20, 2017
fc68193
setting up model
Jul 21, 2017
52e3384
feat(signup): create-account
Jul 22, 2017
7374c11
feat(login): log-user-in
Jul 23, 2017
3e131e8
feat(getUsers): find-users
Jul 23, 2017
f3ed91c
feat(finduser):find-user
Jul 23, 2017
9d99802
feat(user-update): update-user
Jul 23, 2017
b2cda45
feat(user-delete): delete-user
Jul 23, 2017
ced461b
refactor users croute
Jul 23, 2017
9ab604a
refactor users croute
Jul 23, 2017
012ba39
feat(search): search-user
Jul 23, 2017
7e161e9
feat(createDoc): create-document
Jul 23, 2017
75f9717
feat(updateDoc): update-document
Jul 23, 2017
2284755
get all documents and paginations
Jul 23, 2017
c3a0904
add the functionality to find document base on a user access type
Jul 23, 2017
f85428a
feat(find-delete): find-delete
Jul 23, 2017
f6c304a
feat(find-delete): find-delete
Jul 23, 2017
5e123af
find user document
Jul 25, 2017
ad54e5a
feat(getalluserdoc)get-user-documents
Jul 25, 2017
5e0dc2f
feat(search): search-document
Jul 25, 2017
edd9efe
feat(roles): roles
Jul 26, 2017
4f5d186
feat(roles): roles
Jul 27, 2017
6f9bb32
feature(testing routes): routes
Jul 27, 2017
d4bd8c4
feature(testing routes): routes
Jul 27, 2017
590c2aa
feature(testing routes): routes
Jul 30, 2017
c018593
feature(testing routes): routes
Jul 30, 2017
2f4cc16
feature(testing routes): routes
Jul 31, 2017
ad08799
feature(testing routes): routes
Jul 31, 2017
5a6dfbf
feat(test): writing tests
Jul 31, 2017
656a672
feat(test): writing tests
Jul 31, 2017
86c8637
feat(test): testing
Jul 31, 2017
8feb9d0
feat(testing):fixing gulp-mocha coverage
Aug 2, 2017
b76587b
feat(test): resolve gulp coverage
Aug 2, 2017
c571cd5
feat(testing):testing
Aug 3, 2017
aa3df81
remove coverage
Aug 3, 2017
57ea897
remove coverage
Aug 3, 2017
e339055
remove dist
Aug 3, 2017
c07769d
remove .env file
Aug 3, 2017
372623e
remove coverrun
Aug 3, 2017
dfad6b3
remove env file from folder structure
Aug 3, 2017
1616c6d
feat(testing):testing
Aug 3, 2017
d5b1d9d
feat(testing):testing
Aug 3, 2017
228a032
configuring tools
Aug 4, 2017
8a85316
feat(testing):testing
Aug 4, 2017
c4d0280
feat(testing):testing
Aug 4, 2017
3191a98
Merge branch 'feature/149632847/testing' into staging
Aug 4, 2017
4b782df
configuring integration tools
Aug 4, 2017
e202626
feat(testing):testing
Aug 4, 2017
bd2a8fd
feat(testing):testing
Aug 4, 2017
329e47b
Merge branch 'feature/149632847/testing' into staging
Aug 6, 2017
4aa1247
- ensure travis is building
Aug 6, 2017
6acb611
- add env.sample file
Aug 6, 2017
89648e0
- add middleware test
Aug 6, 2017
5adc7fd
feat(testing):test
Aug 7, 2017
c8f57ff
feat(testing):test
Aug 7, 2017
3c499e3
feat(testing):test
Aug 7, 2017
4038a35
feat(testing):test
Aug 7, 2017
8a72ba0
feat(testing):test
Aug 7, 2017
aeaec1d
feat(documentation): document-api
Aug 7, 2017
a32145a
feat(documentation): document-api
Aug 10, 2017
54a9aa7
set up production database
Aug 10, 2017
533a9fd
set up production database
Aug 10, 2017
3d1f2ce
set up production database
Aug 10, 2017
c7a188f
set up production database
Aug 10, 2017
dcdb88c
refactoring code
Aug 11, 2017
03a1d87
refactoring code
Aug 11, 2017
4b51cde
refactoring code
Aug 11, 2017
db56f1d
remove hard coded data in spec
Aug 13, 2017
564d371
remove hard coded data in spec
Aug 13, 2017
3d2a2d7
remove hard coded data in spec
Aug 13, 2017
110820d
remove hard coded data in spec
Aug 13, 2017
25921ec
refactor swagger
Aug 13, 2017
b07bc55
refactor swagger
Aug 13, 2017
08c2cdc
refactor documentation
Aug 14, 2017
944071b
refactor documentation
Aug 14, 2017
999cadf
modify swagger
Aug 15, 2017
d0004e4
modify swagger
Aug 15, 2017
b040dd6
modify swagger
Aug 15, 2017
6543e1a
refactor change
Aug 16, 2017
db21225
feat(feedback):user modification
Aug 16, 2017
9fbe7c2
feat(feedback):user modification
Aug 16, 2017
adba1f5
feat(feedback)dynamic search and test
Aug 17, 2017
096bacf
feat(feedback)dynamic search and test
Aug 17, 2017
f4299eb
feat(feedback)Read me
Aug 17, 2017
ed07e11
feat(feedback) test
Aug 17, 2017
99289ac
modify readme
Aug 18, 2017
0aab61b
modify readme
Aug 18, 2017
58f5831
modify readme
Aug 18, 2017
8568f9a
implementing feedback
Aug 18, 2017
66faa5d
feat(feedback)feedback implementation
Aug 18, 2017
296b228
feat(feedback)feedback implementation
Aug 18, 2017
bc75838
merge feedback
Aug 18, 2017
0f343b5
feature(feedback)updating
Aug 18, 2017
0fb0854
feature(feedback)updating
Aug 18, 2017
b361e10
Merge branch 'feedback' into staging
Aug 18, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eslint:
enabled: true
config_file: .eslintrc
12 changes: 12 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
"es2015"
],
"env": {
"test": {
"plugins": [
"istanbul"
]
}
}
}
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repo_token: XfNKTpzGyMpLobup5VwEThnBUw1sre4NX
6 changes: 6 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
JWT_SECRET=''
TEST_ADMIN_PASSWORD=''
TEST_FELLOW_PASSWORD=''
TEST_FACILITATOR_PASSWORD=''
PASSWORD=''
TEST_DB=''
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
34 changes: 34 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"root": true,
"extends": "airbnb-base",
"env": {
"node": true,
"es6": true,
"mocha": true
},
"rules": {
"one-var": 0,
"one-var-declaration-per-line": 0,
"new-cap": 0,
"consistent-return": 0,
"no-param-reassign": 0,
"comma-dangle": 0,
"curly": ["error", "multi-line"],
"import/no-unresolved": [0, { commonjs: true, amd: true }],
"max-len": [2, 80, 2],
"no-shadow": ["error", { "allow": ["req", "res", "err"] }],
"valid-jsdoc": ["error", {
"requireReturn": true,
"requireReturnType": true,
"requireParamDescription": false,
"requireReturnDescription": true
}],
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true
}
}]
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
coverage
.nyc_output
.DS_Store
.env
dist/
.coverdata/
.coverrun
npm-debug.log
8 changes: 8 additions & 0 deletions .sequelizerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path');

module.exports = {
"config": path.resolve('./server/config', 'config.js'),
"models-path": path.resolve('./server/models'),
"seeders-path": path.resolve('./server/seeders'),
"migrations-path": path.resolve('./server/migrations')
};
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: node_js
node_js:
- '6'
before_script:
- npm install -g gulp-cli
script: npm test
after_success:
- npm install -g codeclimate-test-reporter
- codeclimate-test-reporter < ./coverage/lcov.info
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npm start
113 changes: 112 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,112 @@
# document-manager
[![Build Status](https://travis-ci.org/iakhator/document-manager.svg?branch=staging)](https://travis-ci.org/iakhator/document-manager)
[![Coverage Status](https://coveralls.io/repos/github/iakhator/document-manager/badge.svg?branch=staging)](https://coveralls.io/github/iakhator/document-manager?branch=staging)
[![Code Climate](https://codeclimate.com/github/codeclimate/codeclimate/badges/gpa.svg)](https://codeclimate.com/github/codeclimate/codeclimate)

# document-manager
Document manager provides REST API endpoints for a document management system. It allows create, retrieve, update and delete actions to be carried out.
It also ensures that users are authorized.

# API Documentation
The API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API status and errors. Go to documentation [doksmanager](http://doksmanager.herokuapp.com)

## Features

**Users**:
A created user will have a role, either an admin or a fellow.
- A Fellow User can:
- Create an account: User can create a new account.
- Search users: search for a specific user by Id.
- Create a document: User can create document and assign an access type to each document created.
- Edit a document: User can edit/update document by the document Id.
- Retrieve a document: User can retrieve document based on access type or roles
- Delete a document: User can delete document by Id if the Id matches the logged in id.
- Limit access to a document by specifying an access group `i.e. public, private or role`.
- View public documents created by other user
- View documents created by his access group with access level set as `role`.
- Search documents: User can search through document to get all document related to the search query.
- View `public` and `role` access level documents of other fellows.

- An Admin User can:
- View all users: An admin has the right to view all users
- View all created documents: An admin can view all documents
- Delete any user: An admin can delete any user by the user Id.
- Update any user's role: An admin can update user Role
- Create a new role if more roles are needed
- View all created roles
- Search for any user
- Search for any document

**Documents**:
Documents can be created and must have:
- Published date: This is the created date and updated date of new document created
- Title: This is the required title field of the document to be created.
- Content: This is the body of the document created
- Access (`private, public or role`): This is the access type of the document created.

**Roles**:
Roles can also be created, the default roles are `admin` and `fellow`.
Only an admin user can create and manage role(s)

**Authentication**:
Users are authenticated and validated using JSON web token (JWT).
By generating a token on login, API endpoints and documents are protected from unauthorized access.
Requests to protected routes are validated using the generated token.

## Development
Document Management System API is built with the following technologies;
- EcmaScript6 (ES6)
- [NodeJs](https://nodejs.org)
- [Express](http://expressjs.com/)
- [Postgresql](https://www.postgresql.org/)
- [Sequelize ORM](http://docs.sequelizejs.com/en/v3/)

## Installation
- Install [NodeJs](https://nodejs.org/en/) and [Postgres](https://www.postgresql.org/) on your machine
- Clone the repository `$ git clone https://github.com/iakhator/document-manager.git`
- Change into the directory `$ cd /document-manager`
- Install all required dependencies with `$ npm install`
- Create a `.env` file in your root directory as described in `.env.sample` file
- Start the app with `npm start`

## Testing
- Open a terminal and navigate to the project directory
- Add a test database url (DATABASE_URL) to the .env file.(optional)
- Run `npm test`

## Contributing
- Fork this repository to your GitHub account
- Clone the forked repository
- Create your feature branch
- Commit your changes
We recommend that commit messages have a Header, Body and Footer.

```
feature(): This feature addresses some particular issue(s)
- implements functionality A.
- implements functionality B.
[Delivers #STORY_ID]

```
- Push to the remote branch
- Open a Pull Request
We recommend that pull requests follow this convention:

```
- Describe what this PR does
- How should this be manually tested?
- Any background context you want to provide?
- Screenshots (if appropriate)
- Questions:

```

## Limitations
The limitations of the API are:
- The application cannot accommodate millions of users for now because the database only allow limited number of users since it is a free account.
- Users cannot share documents with other users through social sharing

## FAQ
- If there are any question you want to ask, contact me via mail [[email protected]](mailto:[email protected])

## LICENSE
This project is authored by [Itua Akhator](https://github.com/iakhator) it is licensed under the MIT license.
20 changes: 20 additions & 0 deletions codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
engines:
eslint:
enabled: true
config:
config: .eslintrc
duplication:
enabled: false
config:
languages:
- javascript
fixme:
enabled: true
ratings:
paths:
- "**.es6"
- "**.js"
- "**.jsx"
exclude_paths:
- node_modules/**/*
- test/
41 changes: 41 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import gulp from 'gulp';
import loadPlugins from 'gulp-load-plugins';
import path from 'path';
import shell from 'gulp-shell';

// Load the gulp plugins into the `plugins` variable
const plugins = loadPlugins();

// Compile all Babel Javascript into ES5 and place in dist folder
const paths = {
js: ['./**/*.js', '!dist/**', '!node_modules/**', '!./server/tests/**']
};

// Compile all Babel Javascript into ES5 and put it into the dist dir
gulp.task('babel', () =>
gulp.src(paths.js, { base: '.' })
.pipe(plugins.babel())
.pipe(gulp.dest('dist'))
);

gulp.task('migrate', shell.task([
'cross-env NODE_ENV=test sequelize db:migrate',
]));

gulp.task('coverage', shell.task([
'cross-env NODE_ENV=test nyc mocha ./server/test/**/*.js',
]));

// Restart server with on every changes made to file
gulp.task('nodemon', ['babel'], () =>
plugins.nodemon({
script: path.join('dist', 'index.js'),
ignore: ['README.md', 'node_modules/**/*.js', 'dist/**/*.js'],
ext: 'js',
tasks: ['babel']
})
);

gulp.task('test', ['migrate', 'coverage']);
gulp.task('default', ['nodemon']);
gulp.task('production', ['babel']);
72 changes: 72 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import express from 'express';
import path from 'path';
import bodyParser from 'body-parser';
import logger from 'morgan';
import expressValidator from 'express-validator';
import swaggerJSDoc from 'swagger-jsdoc';
import routes from './server/routes';

const app = express();

const port = process.env.PORT || 3000
// swagger definition
const swaggerDefinition = {
info: {
title: 'Doksmanager API',
version: '1.0.0',
description: 'Doksmanager API is the API for a document management system, complete with roles and privileges. Each document defines access rights; the document defines which roles can access it. Also, each document specifies the date it was published. Users are categorized by roles. Each user must have a role defined for them.',
contact: {
email: '[email protected]',
},
license: {
name: 'MIT',
url: 'http://www.apache.org/licenses/LICENSE-2.0.html',
}
},
host: 'doksmanager.herokuapp.com',
basePath: '/',
};

// options for the swagger docs
const options = {
// import swaggerDefinitions
swaggerDefinition,
// path to the API docs
apis: [path.join(__dirname, './server/routes/*.js')],
};
const swaggerSpec = swaggerJSDoc(options);

app.use(logger('dev'));

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(expressValidator());

// initialize swagger-jsdoc
app.use(express.static('public/api-doc'));

// serve swagger
app.get('/swagger.json', (req, res) => {
res.setHeader('Content-Type', 'application/json');
res.send(swaggerSpec);
});

app.use((req, res, next) => {
const send = res.send;
let sent = false;
res.send = (data) => {
if (sent) return;
send.bind(res)(data);
sent = true;
};
next();
});

// mount all routes on /api path
app.use('/api/v1', routes);

const server = app.listen(port, () => {
console.log('API Server started and listening on port 3000');
});

export default server;
Loading