User routes
parent
b35a5b26c0
commit
2091dae63b
|
@ -1,5 +1,11 @@
|
|||
module.exports = (req, res) => {
|
||||
const users = [];
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
res.status(200).json({ users });
|
||||
module.exports = (req, res) => {
|
||||
const UserModel = mongoose.model('User');
|
||||
const users = UserModel.find()
|
||||
.lean()
|
||||
.exec()
|
||||
.then(() => {
|
||||
res.status(200).json(users);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
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');
|
|
@ -3,9 +3,9 @@ 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 create = require('./create');
|
||||
// const update = require('./update');
|
||||
// const remove = require('./delete');
|
||||
|
||||
/**
|
||||
* @api {get} /user Request all Users information
|
||||
|
@ -62,9 +62,9 @@ user.put('/me', profile);
|
|||
* @apiParam {String} lastname Lastname of the User.
|
||||
* @apiParam {String} username Username of the User.
|
||||
*/
|
||||
user.delete('/me', profile);
|
||||
user.delete('/me', profile);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @api {get} /user/me/notes Get notes created by this account
|
||||
* @apiName GetNotes
|
||||
* @apiGroup User,Note
|
||||
|
@ -72,10 +72,10 @@ user.put('/me', profile);
|
|||
* @apiSuccess {string} title Title of the note.
|
||||
* @apiSuccess {string} text Text of the note.
|
||||
*/
|
||||
user.get('/me/notes', profile);
|
||||
user.get('/me/notes', profile);
|
||||
|
||||
//user.post('/', create)
|
||||
//user.put('/:userId', update)
|
||||
//user.delete('/:userId', remove)
|
||||
// user.post('/', create)
|
||||
// user.put('/:userId', update)
|
||||
// user.delete('/:userId', remove)
|
||||
|
||||
module.exports = user;
|
||||
|
|
Loading…
Reference in New Issue