Skip to content

Commit

Permalink
issue #62 | update api and api-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezumezu Chukwuma committed Jan 6, 2017
1 parent c0746c3 commit 8a2653c
Show file tree
Hide file tree
Showing 20 changed files with 605 additions and 44 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"lint": "gulp lint",
"test": "babel-node ./node_modules/.bin/_mocha",
"cover": "rm -rf coverage/ && babel-node ./node_modules/babel-istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec",
"cover": "rm -rf coverage/ && babel-node ./node_modules/babel-istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"commitmsg": "babel-node commitValidator.js commit && npm run lint",
"start": "babel-node server.js"
Expand All @@ -33,6 +33,7 @@
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-eslint": "^3.0.1",
"mongoose": "^4.7.6",
"tracer": "^0.8.7"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import express from 'express';
import bodyParser from 'body-parser';
import 'dotenv/config';
import Logger from './Logger.js';
import './server/models/db.js';

/**
* Import app routes
*/
import homepage from './server/routes/index.js';
import authRoute from './server/routes/auth.js';
import usersRoute from './server/routes/users.js';
import docsRoute from './server/routes/documents.js';
import docTemplateRoute from './server/routes/templates';
import docCategoryRoute from './server/routes/categories.js';

const app = express();
Expand All @@ -23,7 +24,7 @@ app.use(bodyParser.urlencoded({ extended: true }));
app.use('/', homepage);
app.use('/api/v1/auth', authRoute);
app.use('/api/v1/users', usersRoute);
app.use('/api/v1/templates', docsRoute);
app.use('/api/v1/templates', docTemplateRoute);
app.use('/api/v1/categories', docCategoryRoute);

/**
Expand Down
53 changes: 53 additions & 0 deletions server/controllers/auth-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import User from '../models/user-model.js';

/**
* AuthController
*
* Handles requests made to /api/v1/auth
*/
class AuthController {

/**
* signup
*
* Registers a new user
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} User
*/
signup(req, res, next) {
res.send({ content: 'signup' });
}

/**
* signin
*
* Logs in a registered user
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} User
*/
signin(req, res, next) {
res.send({ content: 'signin' });
}

/**
* signout
*
* Logs out a logged in user
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {String} Success or Failure
*/
signout(req, res, next) {
res.send({ content: 'signout' });
}
}

export default new AuthController();
89 changes: 89 additions & 0 deletions server/controllers/docCategory-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import DocumentCategory from '../models/category-model.js';

/**
* DocumentCategoryControl
*
* handles requests made to /api/v1/categories
*/
class DocumentCategoryControl {

/**
* getCategories
*
* Gets all category names
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object[]} Categories
*/
getCategories(req, res, next) {
res.send({ content: 'get all doc categories' });
}

/**
* getCategory
*
* Gets a category name
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Category
*/
getCategory(req, res, next) {
res.send({ content: 'get the name of the category' });
}

/**
* getCategoryDocuments
*
* Gets a category name
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Category
*/
getCategoryDocuments(req, res, next) {
res.send({ content: 'get docs from a specified category' });
}

/**
* addCategory
*
* Adds a new category names
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Categories
*/
addCategory(req, res, next) {
res.send({ content: 'add a new category' });
}

/**
* editCategory
*
* Edits a category data
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Category
*/
editCategory(req, res, next) {
res.send({ content: 'edit a category' });
}

/**
* deleteCategory
*
* Delete a category data
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Category
*/
deleteCategory(req, res, next) {
res.send({ content: 'delete a category' });
}
}

export default new DocumentCategoryControl();
71 changes: 71 additions & 0 deletions server/controllers/docTemplate-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import DocumentTemplate from '../models/templates-model.js';

/**
* DocumentTemplateControl
*
* Handles requests made to /api/v1/templates
*/
class DocumentTemplateControl {

/**
* getTemplates
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object[]} Templates
*/
getTemplates(req, res, next) {
res.send({ content: 'get all templates' });
}

/**
* getTemplate
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Template
*/
getTemplate(req, res, next) {
res.send({ content: 'get a particulatr template' });
}

/**
* addTemplates
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Template
*/
addTemplates(req, res, next) {
res.send({ content: 'add a template' });
}

/**
* editTemplates
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Template
*/
editTemplates(req, res, next) {
res.send({ content: 'edit a template' });
}

/**
* deleteTemplates
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Template
*/
deleteTemplates(req, res, next) {
res.send({ content: 'delete a template' });
}
}

export default new DocumentTemplateControl();
136 changes: 136 additions & 0 deletions server/controllers/user-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import User from '../models/user-model.js';

/**
* UserController class.
* Handles requests made to the /api/v1/users endpoint
*/
class UserController {

/**
* getAllUsers
*
* Gets all registered users.
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object[]} Users
*/
getAllUsers(req, res, next) {
res.send({ content: 'get all users' });
}

/**
* getOneUser
*
* Gets a specified user.
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} User
*/
getOneUser(req, res, next) {
res.send({ content: 'get single user' });
}

/**
* editUser
*
* Edits a users data.
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Users
*/
editUser(req, res, next) {
res.send({ content: 'edit single user' });
}

/**
* deleteUser
*
* Deletes a users data.
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Users
*/
deleteUser(req, res, next) {
res.send({ content: 'deletes a user' });
}

/**
* getUserDocuments
*
* Get all documents belonging to a user.
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object[]} Document
*/
getUserDocuments(req, res, next) {
res.send({ content: 'get a user\'s documents' });
}

/**
* getUserDocument
*
* Get a specified document belonging to a user.
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Document
*/
getUserDocument(req, res, next) {
res.send({ content: 'get a specified document from a specified user' });
}

/**
* createDocument
*
* Save a customized document.
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Document
*/
createDocument(req, res, next) {
res.send({ content: 'add a document' });
}

/**
* editUserDocument
*
* Edits a users document.
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Document
*/
editUserDocument(req, res, next) {
res.send({ content: 'edit a specified document' });
}

/**
* deleteUserDocument
*
* Deletes a users document.
*
* @param {Object} req
* @param {Object} res
* @param {Object} next
* @returns {Object} Users
*/
deleteUserDocument(req, res, next) {
res.send({ content: 'delete a specified document' });
}
}

export default new UserController();
Loading

0 comments on commit 8a2653c

Please sign in to comment.