Example #1
0
const register: PluginRegister = (server, _, next) => {

  server.route([
    {
      method: 'POST',
      path: '/users',
      handler: {
        async: createUser,
      },
      config: {
        auth: 'attendee',
        validate: {
          payload: Joi.object().keys({
            data: Joi.object().keys({
              id: Joi.string(),
              type: Joi.only('users'),
              attributes: Joi.object().keys({
                name: Joi.string(),
              }),
            }),
          }),
        },
      },
    },
    {
      method: 'GET',
      path: '/users',
      handler: {
        async: getUsers,
      },
      config: {
        cors: true,
      },
    },
    {
      method: 'GET',
      path: '/users/{userId}',
      handler: {
        async: getUser,
      },
      config: {
        cors: true,
        validate: {
          params: {
            userId: Joi.string(),
          },
        },
      },
    },
  ])

  next()
}
Example #2
0
const register: PluginRegister = (server, _, next) => {

  server.route([
    {
      method: 'POST',
      path: '/attendees',
      handler: {
        async: createAttendee,
      },
      config: {
        auth: 'admin',
        validate: {
          payload: Joi.object().keys({
            data: Joi.object().keys({
              id: Joi.string(),
              type: Joi.only('attendees'),
            }),
          }),
        },
      },
    }, {
      method: 'DELETE',
      path: '/attendees/{attendeeId}',
      handler: {
        async: deleteAttendee,
      },
      config: {
        auth: 'admin',
        validate: {
          params: {
            attendeeId: Joi.string(),
          },
        },
        response: {
          emptyStatusCode: 204,
        },
      },
    }, {
      method: 'GET',
      path: '/attendees',
      handler: {
        async: getAttendees,
      },
      config: {
        auth: 'admin',
      },
    }, {
      method: 'GET',
      path: '/attendees/{attendeeId}',
      handler: {
        async: getAttendee,
      },
      config: {
        auth: 'admin',
        validate: {
          params: {
            attendeeId: Joi.string(),
          },
        },
      },
    },
  ])

  next()
}
Example #3
0
const register: PluginRegister = (server, _, next) => {

  server.route([
    {
      method: 'POST',
      path: '/challenges',
      handler: {
        async: createChallenge,
      },
      config: {
        auth: 'admin',
        validate: {
          payload: Joi.object().keys({
            data: Joi.object().keys({
              id: Joi.string(),
              type: Joi.only('challenges'),
              attributes: Joi.object().keys({
                name: Joi.string(),
              }),
            }),
          }),
        },
      },
    }, {
      method: 'DELETE',
      path: '/challenges/{challengeId}',
      handler: {
        async: deleteChallenge,
      },
      config: {
        auth: 'admin',
        validate: {
          params: {
            challengeId: Joi.string(),
          },
        },
        response: {
          emptyStatusCode: 204,
        },
      },
    }, {
      method: 'GET',
      path: '/challenges',
      handler: {
        async: getChallenges,
      },
      config: {
        cors: true,
      },
    }, {
      method: 'GET',
      path: '/challenges/{challengeId}',
      handler: {
        async: getChallenge,
      },
      config: {
        cors: true,
        validate: {
          params: {
            challengeId: Joi.string(),
          },
        },
      },
    },
  ])

  next()
}
Example #4
0
import * as Joi from 'joi'
import { PluginRegister } from '../../../hapi.types'
import addTeamEntries from './add-team-entries'
import deleteTeamEntries from './delete-team-entries'
import getTeamEntries from './get-team-entries'

const multipleEntriesSchema = Joi.object().keys({
  data: Joi.array().items(
    Joi.object().keys({
      id: Joi.string(),
      type: Joi.only('hacks'),
    }),
  ),
})

const register: PluginRegister = (server, _, next) => {

  server.route([
    {
      method: 'POST',
      path: '/teams/{teamId}/entries',
      handler: {
        async: addTeamEntries,
      },
      config: {
        auth: 'attendee',
        validate: {
          params: {
            teamId: Joi.string(),
          },
          payload: multipleEntriesSchema,
Example #5
0
import * as Joi from 'joi'
import { PluginRegister } from '../../../hapi.types'
import addHackChallenges from './add-hack-challenges'
import deleteHackChallenges from './delete-hack-challenges'
import getHackChallenges from './get-hack-challenges'

const multipleChallengesSchema = Joi.object().keys({
  data: Joi.array().items(
    Joi.object().keys({
      id: Joi.string(),
      type: Joi.only('challenges'),
    }),
  ),
})

const register: PluginRegister = (server, _, next) => {

  server.route([
    {
      method: 'POST',
      path: '/hacks/{hackId}/challenges',
      handler: {
        async: addHackChallenges,
      },
      config: {
        auth: 'attendee',
        validate: {
          params: {
            hackId: Joi.string(),
          },
          payload: multipleChallengesSchema,
Example #6
0
import * as Joi from 'joi'
import { PluginRegister } from '../../../hapi.types'
import addTeamMembers from './add-team-members'
import deleteTeamMembers from './delete-team-members'
import getTeamMembers from './get-team-members'

const multipleMembersSchema = Joi.object().keys({
  data: Joi.array().items(
    Joi.object().keys({
      id: Joi.string(),
      type: Joi.only('users'),
    }),
  ),
})

const register: PluginRegister = (server, _, next) => {

  server.route([
    {
      method: 'POST',
      path: '/teams/{teamId}/members',
      handler: {
        async: addTeamMembers,
      },
      config: {
        auth: 'attendee',
        validate: {
          params: {
            teamId: Joi.string(),
          },
          payload: multipleMembersSchema,
Example #7
0
const register: PluginRegister = (server, _, next) => {

  server.route([
    {
      method: 'POST',
      path: '/teams',
      handler: {
        async: createTeam,
      },
      config: {
        auth: 'attendee',
        validate: {
          payload: Joi.object().keys({
            data: Joi.object().keys({
              id: Joi.string(),
              type: Joi.only('teams'),
              attributes: Joi.object().keys({
                name: Joi.string(),
                motto: Joi.string(),
              }).optionalKeys('motto'),
              relationships: Joi.object().keys({
                entries: multipleEntriesSchema,
                members: multipleMembersSchema,
              }).optionalKeys('entries', 'members'),
            }).optionalKeys('relationships'),
          }),
        },
      },
    },
    {
      method: 'DELETE',
      path: '/teams/{teamId}',
      handler: {
        async: deleteTeam,
      },
      config: {
        auth: 'attendee',
        validate: {
          params: {
            teamId: Joi.string(),
          },
        },
        response: {
          emptyStatusCode: 204,
        },
      },
    },
    {
      method: 'GET',
      path: '/teams',
      handler: {
        async: getTeams,
      },
      config: {
        cors: true,
      },
    },
    {
      method: 'GET',
      path: '/teams/{teamId}',
      handler: {
        async: getTeam,
      },
      config: {
        cors: true,
        validate: {
          params: {
            teamId: Joi.string(),
          },
        },
      },
    },
    {
      method: 'PATCH',
      path: '/teams/{teamId}',
      handler: {
        async: updateTeam,
      },
      config: {
        auth: 'attendee',
        validate: {
          params: {
            teamId: Joi.string(),
          },
          payload: Joi.object().keys({
            data: Joi.object().keys({
              id: Joi.string(),
              type: Joi.only('teams'),
              attributes: Joi.object().keys({
                name: Joi.string(),
                motto: Joi.string(),
              }).optionalKeys('name', 'motto'),
            }).optionalKeys('attributes'),
          }),
        },
        response: {
          emptyStatusCode: 204,
        },
      },
    },
  ])

  next()
}
Example #8
0
import * as Joi from 'joi'
import { PluginRegister } from '../../../hapi.types'
import createTeam from './create-team'
import deleteTeam from './delete-team'
import getTeam from './get-team'
import getTeams from './get-teams'
import updateTeam from './update-team'

const multipleEntriesSchema = Joi.object().keys({
  data: Joi.array().items(
    Joi.object().keys({
      id: Joi.string(),
      type: Joi.only('hacks'),
    }),
  ),
})

const multipleMembersSchema = Joi.object().keys({
  data: Joi.array().items(
    Joi.object().keys({
      id: Joi.string(),
      type: Joi.only('users'),
    }),
  ),
})

const register: PluginRegister = (server, _, next) => {

  server.route([
    {
      method: 'POST',