diff --git a/app/routes/user/all.js b/app/routes/user/all.js deleted file mode 100644 index 9e1d309..0000000 --- a/app/routes/user/all.js +++ /dev/null @@ -1,11 +0,0 @@ -const mongoose = require('mongoose'); - -module.exports = (req, res) => { - const UserModel = mongoose.model('User'); - const users = UserModel.find() - .lean() - .exec() - .then(() => { - res.status(200).json(users); - }); -}; diff --git a/app/routes/user/create.js b/app/routes/user/create.js deleted file mode 100644 index 7098f3c..0000000 --- a/app/routes/user/create.js +++ /dev/null @@ -1,12 +0,0 @@ -const Joi = require('joi'); -// const jwt = require('jsonwebtoken'); -// const bcrypt = require('bcrypt-nodejs'); - -const schema = Joi.object().keys({ - firstname: Joi.string().alphanum().min(2), - lastname: Joi.string().alphanum().min(2), - username: Joi.string().alphanum().min(3).max(30) - .required(), - password: Joi.string().regex(/^[a-zA-Z0-9]{3,30}$/), - access_token: [Joi.string(), Joi.number()], -}).with('username').without('password', 'access_token'); diff --git a/app/routes/user/delete.js b/app/routes/user/delete.js index e69de29..0e97c8b 100644 --- a/app/routes/user/delete.js +++ b/app/routes/user/delete.js @@ -0,0 +1,5 @@ +module.exports = (req, res) => { + const user = {}; + + res.status(200).json({ user }); +}; diff --git a/app/routes/user/index.js b/app/routes/user/index.js index f80dee0..0f5d429 100644 --- a/app/routes/user/index.js +++ b/app/routes/user/index.js @@ -1,38 +1,12 @@ const user = require('express').Router(); -const all = require('./all'); const profile = require('./profile'); -const single = require('./single'); -// const create = require('./create'); -// const update = require('./update'); -// const remove = require('./delete'); +const update = require('./update'); +const remove = require('./delete'); +// const notes = require('./notes'); /** - * @api {get} /user Request all Users information - * @apiName GetUsers - * @apiGroup User - * - * @apiParam {Number} id Users unique ID. - * - * @apiSuccess {Array} Array User objects. - */ -user.get('/', all); - -/** - * @api {get} /user/:id Request User information - * @apiName GetUser - * @apiGroup User - * - * @apiParam {Number} id Users unique ID. - * - * @apiSuccess {String} firstname Firstname of the User. - * @apiSuccess {String} lastname Lastname of the User. - * @apiSuccess {String} username Username of the User. - */ -user.get('/:userId', single); - -/** - * @api {get} /user/me Request current account information + * @api {get} /user/me Get user information * @apiName GetUser * @apiGroup User * @@ -43,39 +17,28 @@ user.get('/:userId', single); user.get('/me', profile); /** - * @api {put} /user/me Update current account information - * @apiName UpdateUser - * @apiGroup User - * - * @apiParam {String} firstname Firstname of the User. - * @apiParam {String} lastname Lastname of the User. - * @apiParam {String} username Username of the User. - */ -user.put('/me', profile); + * @api {put} /user/me Update account information + * @apiName UpdateUser + * @apiGroup User + * + * @apiSuccess {Object} user User object. + */ +user.put('/me', update); /** - * @api {delete} /user/me Delete current account + * @api {delete} /user/me Delete account * @apiName DeleteUser * @apiGroup User - * - * @apiParam {String} firstname Firstname of the User. - * @apiParam {String} lastname Lastname of the User. - * @apiParam {String} username Username of the User. */ -user.delete('/me', profile); +user.delete('/me', remove); /** - * @api {get} /user/me/notes Get notes created by this account - * @apiName GetNotes - * @apiGroup User,Note + * @api {get} /user/me/notes Get all notes + * @apiName GetNotesByUserId + * @apiGroup User notes * - * @apiSuccess {string} title Title of the note. - * @apiSuccess {string} text Text of the note. + * @apiSuccess {Array} Array Notes of the user. */ user.get('/me/notes', profile); -// user.post('/', create) -// user.put('/:userId', update) -// user.delete('/:userId', remove) - module.exports = user; diff --git a/app/routes/user/notes.js b/app/routes/user/notes.js new file mode 100644 index 0000000..e69de29 diff --git a/app/routes/user/single.js b/app/routes/user/single.js deleted file mode 100644 index fda0e54..0000000 --- a/app/routes/user/single.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = (req, res) => { - const user = req.model; - - res.status(200).json({ user }); -}; diff --git a/app/routes/user/update.js b/app/routes/user/update.js index e69de29..0e97c8b 100644 --- a/app/routes/user/update.js +++ b/app/routes/user/update.js @@ -0,0 +1,5 @@ +module.exports = (req, res) => { + const user = {}; + + res.status(200).json({ user }); +};