Skip to content

Commit b189bdf

Browse files
authored
Merge pull request #59 from CCIP-App/feat/attendee-import-api#39
Add POST /admin/attendees as attendee import API
2 parents ff59f66 + 84919ff commit b189bdf

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

features/attendee_import.feature

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Feature: Attendee Importation
2+
Scenario: POST /admin/attendees with a CSV file that contains attendee information
3+
When I make a POST request to "/admin/attendees" with file:
4+
"""
5+
token,display_name,
6+
"fccfc8bfa07643a1ca8015cbe74f5f17","Aotoki",
7+
"93dc46e553ac602b0d6c6d7307e523f1","Danny",
8+
"""
9+
Then the response status should be 200

features/support/apiSteps.ts

+13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ When(
2020
}
2121
)
2222

23+
When(
24+
'I make a POST request to {string} with file:',
25+
async function (this: WorkerWorld, path: string, content: string) {
26+
const formData = new FormData()
27+
formData.append('file', content)
28+
this.apiResponse = await this.api.fetch(`https://ccip.opass.app${path}`, {
29+
method: 'POST',
30+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
31+
body: formData,
32+
})
33+
}
34+
)
35+
2336
When(
2437
'I make a PUT request to {string}:',
2538
async function (this: WorkerWorld, path: string, payload: string) {

worker/controller/attendee.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { OpenAPIRoute, OpenAPIRouteSchema } from '@cloudflare/itty-router-openapi'
2+
import { Post } from '@worker/router'
3+
import { IRequest, status } from 'itty-router'
4+
5+
export type AttendeeRequest = IRequest
6+
7+
@Post('/admin/attendees')
8+
export class CreateAttendees extends OpenAPIRoute {
9+
static schema: OpenAPIRouteSchema = {
10+
summary: 'Creates attendees',
11+
tags: ['Attendee'],
12+
responses: {
13+
'200': {
14+
description: 'Creates attendees',
15+
},
16+
},
17+
}
18+
19+
async handle(_request: AttendeeRequest) {
20+
return status(200)
21+
}
22+
}

worker/controller/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './announcement'
2+
export * from './attendee'
23
export * from './landing'
34
export * from './status'
45
export * from './use'

0 commit comments

Comments
 (0)