diff --git a/features/attendee_import.feature b/features/attendee_import.feature new file mode 100644 index 0000000..ea58e39 --- /dev/null +++ b/features/attendee_import.feature @@ -0,0 +1,9 @@ +Feature: Attendee Importation + Scenario: POST /admin/attendees with a CSV file that contains attendee information + When I make a POST request to "/admin/attendees" with file: + """ + token,display_name, + "fccfc8bfa07643a1ca8015cbe74f5f17","Aotoki", + "93dc46e553ac602b0d6c6d7307e523f1","Danny", + """ + Then the response status should be 200 diff --git a/features/support/apiSteps.ts b/features/support/apiSteps.ts index 032f028..b2b2aaf 100644 --- a/features/support/apiSteps.ts +++ b/features/support/apiSteps.ts @@ -20,6 +20,19 @@ When( } ) +When( + 'I make a POST request to {string} with file:', + async function (this: WorkerWorld, path: string, content: string) { + const formData = new FormData() + formData.append('file', content) + this.apiResponse = await this.api.fetch(`https://ccip.opass.app${path}`, { + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: formData, + }) + } +) + When( 'I make a PUT request to {string}:', async function (this: WorkerWorld, path: string, payload: string) { diff --git a/worker/controller/attendee.ts b/worker/controller/attendee.ts new file mode 100644 index 0000000..7d1814e --- /dev/null +++ b/worker/controller/attendee.ts @@ -0,0 +1,22 @@ +import { OpenAPIRoute, OpenAPIRouteSchema } from '@cloudflare/itty-router-openapi' +import { Post } from '@worker/router' +import { IRequest, status } from 'itty-router' + +export type AttendeeRequest = IRequest + +@Post('/admin/attendees') +export class CreateAttendees extends OpenAPIRoute { + static schema: OpenAPIRouteSchema = { + summary: 'Creates attendees', + tags: ['Attendee'], + responses: { + '200': { + description: 'Creates attendees', + }, + }, + } + + async handle(_request: AttendeeRequest) { + return status(200) + } +} diff --git a/worker/controller/index.ts b/worker/controller/index.ts index 7c286e4..7804038 100644 --- a/worker/controller/index.ts +++ b/worker/controller/index.ts @@ -1,4 +1,5 @@ export * from './announcement' +export * from './attendee' export * from './landing' export * from './status' export * from './use'