From ad7158f2c8764c199c7afb850e6837d46a31a64b Mon Sep 17 00:00:00 2001 From: Bradley Greenwood Date: Wed, 6 Jun 2018 17:27:56 -0700 Subject: [PATCH] adding id params for specific routes so we can update through swagger (#222) * adding id params for specific routes so we can update through swagger * linter fixes --- server/api/accounts.js | 27 +++++++++++++++++++++++++++ server/api/admin-groups.js | 5 +++++ server/api/admins.js | 10 ++++++++++ server/api/sessions.js | 10 ++++++++++ server/api/statuses.js | 13 +++++++++++++ server/api/users.js | 5 +++++ 6 files changed, 70 insertions(+) diff --git a/server/api/accounts.js b/server/api/accounts.js index 921bf02..6babf0f 100644 --- a/server/api/accounts.js +++ b/server/api/accounts.js @@ -73,6 +73,11 @@ const register = function (server, serverOptions) { tags: ['api','accounts'], description: 'Get a customer account by ID. [Admin Scope]', notes: 'Get a customer account by ID.', + validate: { + params: { + id : Joi.string().required().description('the id to get the account') + } + }, auth: { scope: 'admin' } @@ -107,6 +112,9 @@ const register = function (server, serverOptions) { middle: Joi.string().allow(''), last: Joi.string().required() }).required() + }, + params: { + id : Joi.string().required().description('the id to update the account') } } }, @@ -136,6 +144,11 @@ const register = function (server, serverOptions) { tags: ['api','accounts'], description: 'Delete a customer account by ID. [Root Scope]', notes: 'Delete a customer account by ID.', + validate: { + params: { + id : Joi.string().required().description('the id to delete the account') + } + }, auth: { scope: 'admin' }, @@ -169,6 +182,9 @@ const register = function (server, serverOptions) { validate: { payload: { username: Joi.string().lowercase().required() + }, + params: { + id : Joi.string().required().description('the id to link the account to a user') } }, pre: [{ @@ -231,6 +247,11 @@ const register = function (server, serverOptions) { tags: ['api','accounts'], description: 'Unlink a system user to a customer account. [Admin Scope]', notes: 'Unlink a system user to a customer account.', + validate: { + params: { + id : Joi.string().required().description('the id to unlink a user to account') + } + }, auth: { scope: 'admin' }, @@ -291,6 +312,9 @@ const register = function (server, serverOptions) { validate: { payload: { data: Joi.string().required() + }, + params: { + id : Joi.string().required().description('the id to add a new note onto an account') } } }, @@ -334,6 +358,9 @@ const register = function (server, serverOptions) { validate: { payload: { status: Joi.string().required() + }, + params: { + id : Joi.string().required().description('the id to update an account status') } }, pre: [{ diff --git a/server/api/admin-groups.js b/server/api/admin-groups.js index 3df3eef..e0c91da 100644 --- a/server/api/admin-groups.js +++ b/server/api/admin-groups.js @@ -75,6 +75,11 @@ const register = function (server, serverOptions) { tags: ['api','admin-groups'], description: 'Get an admin group by ID. [Root Scope]', notes: 'Get an admin group by ID.', + validate: { + params: { + id : Joi.string().required().description('the id to get an admin group') + } + }, auth: { scope: 'admin' }, diff --git a/server/api/admins.js b/server/api/admins.js index 5fa160a..80f2955 100644 --- a/server/api/admins.js +++ b/server/api/admins.js @@ -76,6 +76,11 @@ const register = function (server, serverOptions) { tags: ['api','admins'], description: 'Get an admin account by ID. [Root Scope]', notes: 'Get an admin account by ID.', + validate: { + params: { + id : Joi.string().required().description('the id to get an admin') + } + }, auth: { scope: 'admin' }, @@ -148,6 +153,11 @@ const register = function (server, serverOptions) { tags: ['api','admins'], description: 'Delete an admin account by ID. [Root Scope]', notes: 'Delete an admin account by ID.', + validate: { + params: { + id : Joi.string().required().description('the id to delete an admin') + } + }, auth: { scope: 'admin' }, diff --git a/server/api/sessions.js b/server/api/sessions.js index c7f89bc..29909ae 100644 --- a/server/api/sessions.js +++ b/server/api/sessions.js @@ -49,6 +49,11 @@ const register = function (server, serverOptions) { tags: ['api','session'], description: 'Get a user session by ID. [Root Scope]', notes: 'Get a user session by ID.', + validate: { + params: { + id : Joi.string().required().description('the id to get session') + } + }, auth: { scope: 'admin' }, @@ -76,6 +81,11 @@ const register = function (server, serverOptions) { tags: ['api','session'], description: 'Delete a user session by ID. [Root Scope]', notes: 'Delete a user session by ID.', + validate: { + params: { + id : Joi.string().required().description('the id to delete a session') + } + }, auth: { scope: 'admin' }, diff --git a/server/api/statuses.js b/server/api/statuses.js index fda6ce7..b321885 100644 --- a/server/api/statuses.js +++ b/server/api/statuses.js @@ -76,6 +76,11 @@ const register = function (server, serverOptions) { tags: ['api','statuses'], description: 'Get a status by ID. [Root Scope]', notes: 'Get a status by ID.', + validate: { + params: { + id : Joi.string().required().description('the id to get status') + } + }, auth: { scope: 'admin' }, @@ -109,6 +114,9 @@ const register = function (server, serverOptions) { validate: { payload: { name: Joi.string().required() + }, + params: { + id : Joi.string().required().description('the id to update a status') } }, pre: [ @@ -141,6 +149,11 @@ const register = function (server, serverOptions) { tags: ['api','statuses'], description: 'Delete a status by ID. [Root Scope]', notes: 'Delete a status by ID.', + validate: { + params: { + id : Joi.string().required().description('the id to delete a status') + } + }, auth: { scope: 'admin' }, diff --git a/server/api/users.js b/server/api/users.js index 93b1d51..eb83ebc 100644 --- a/server/api/users.js +++ b/server/api/users.js @@ -108,6 +108,11 @@ const register = function (server, serverOptions) { tags: ['api','users'], description: 'Get a user by ID. [Root Scope]', notes: 'Get a user by ID.', + validate: { + params: { + id : Joi.string().required().description('the id to get the user') + } + }, auth: { scope: 'admin' },