| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 'use strict'
-
- const Joi = require('joi')
-
- const pluginConfig = {
- handlerType: 'matchque',
- docs: {
- description: 'updates matchque',
- notes: 'Updates MatchQue Table if User chooses to match with another or chooses to delete match',
- },
- }
-
- const validators = {
- // /** Validate the header (cookie check) */
- // // headers: true,
-
- // /** Validate the route params (/active/{thing}) */
- params: Joi.object({ profile_id: Joi.number() }),
-
- // /** Validate the route query (/active/{thing}?limit=10&offset=10) */
- // // query: true,
-
- // /** Validate the incoming payload (POST method) */
-
- payload: Joi.object({
- profile_id_2: Joi.number(),
- reinsert: Joi.boolean(),
- }),
- }
-
- module.exports = {
- method: 'POST',
- path: '/{profile_id}/choose',
- options: {
- ...pluginConfig.docs,
- tags: ['api'],
- /** Protect this route with authentication? */
- auth: false,
- handler: async function (request, h) {
- const { profile_id } = request.params
- const { profile_id_2, reinsert } = request.payload
- const { matchQueService } = request.server.services()
-
- return await matchQueService.markAsDeleted(
- profile_id,
- profile_id_2,
- reinsert,
- )
- },
- /** Validate based on validators object */
- validate: {
- ...validators,
- failAction: 'log',
- },
-
- // couldn't get validate server response working...
-
- /** Validate the server response */
- // response: {
- // schema: Joi.object({
- // ok: Joi.bool(),
- // handler: Joi.string(),
- // data: Joi.object(),
- // }),
- // },
- },
- }
|