Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add POST /admin/attendees as attendee import API #59

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions features/attandee_import.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Feature: Attendee Importation
Scenario: POST /attendees
When I make a POST request to "/attendees" with file "attendees.csv"
Then the response status should be 200
15 changes: 15 additions & 0 deletions features/support/apiSteps.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Then, When } from '@cucumber/cucumber'
import { WorkerWorld } from './world'
import { expect } from 'expect'
import { readFileSync } from 'node:fs'

const nestedAttribute = (obj: any, path: string) =>

Check warning on line 6 in features/support/apiSteps.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
path.split('.').reduce((prev, curr) => prev?.[curr], obj)

When('I make a GET request to {string}', async function (this: WorkerWorld, path: string) {
Expand All @@ -20,6 +21,20 @@
}
)

When(
'I make a POST request to {string} with file {string}',
async function (this: WorkerWorld, path: string, filePath: string) {
const formData = new FormData()
const file = readFileSync(`${__dirname}/data/${filePath}`, 'utf8')
formData.append('file', file)
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) {
Expand Down
59 changes: 59 additions & 0 deletions features/support/data/attendees.csv
dannyh79 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
token,display_name,飲食,個人贊助
"7679f08f7eaeef5e9a65a1738ae2840e","中文","葷",N
"ee33c408df4ffad0c55eaf6ec2420717","test","素",N
"fccfc8bfa07643a1ca8015cbe74f5f17","LINDA","葷",N
"93dc46e553ac602b0d6c6d7307e523f1","BARBARA","素",N
"2f574789271d26a0c569779e8348ab68","ELIZABETH","葷",N
"1a04f8728ffc11a4cdb9bc7dc79caac0","JENNIFER","葷",N
"d2ec0f1f28db8a4c1483c370953b9f0c","MARIA","素",N
"6520d6fa2fee26045104db0364a092e9","SUSAN","葷",N
"50ecac11d697bf76092bccde23607b27","MARGARET","素",N
"125384b0058f0ce2d5aae8e80d94c5d7","DOROTHY","葷",N
"087e78bb1460e7ddbafd6a3e004f095e","LISA","葷",N
"d38c9001982e5601f2d37a0401528754","NANCY","素",N
"5d765c2e8c5243c0adc3af8495841f5d","KAREN","葷",Y
"16e1dc90555abf7b5bf5781882982755","BETTY","素",N
"1aadcabf9f47e932ea6245cfd51c02e8","HELEN","葷",N
"f1349e8156d2b05e23cf72d83a63c0f3","SANDRA","葷",N
"bb0d74e19d0ce01d63af2bd6d44f06df","DONNA","素",N
"8c654d02c35a8040228c3fef4b25e9d4","CAROL","葷",Y
"17bcb36a975e125f9cbea503a54603f0","RUTH","素",N
"0c4facff3bc9879061b4eddb631339fe","SHARON","葷",N
"78e30e2397f1d8fda75eb930dd3dcf87","MICHELLE","葷",N
"6a487514a78c67098054e07d1440c391","LAURA","素",Y
"8a580a71b3c80199e6c7438618b4f030","SARAH","葷",N
"c7847acc730ad24412b68f5c9f5da851","KIMBERLY","葷",N
"aba94b39687829edef692a384dd698aa","DEBORAH","素",N
"4ae0249680951e256954b0b67fddbcc1","JESSICA","葷",N
"e9b4c7c9995d63993007a211b817ef68","SHIRLEY","素",N
"222449320f2c14d54398f21bdbf253a2","CYNTHIA","葷",N
"6edd6937afcabef71c0917d148811d54","ANGELA","葷",N
"84b1701a3964056eb4bb85daee801522","MELISSA","素",N
"307b11ad88ae3897aadd6af42ba78d2d","BRENDA","葷",N
"a4f07c20edb3ca71ba1457f2d79d90b7","AMY","素",N
"99a3afda0f76109b04ae157c38f9fcb6","ANNA","葷",N
"8145928fa6eb669cc201afd6b52a7f98","REBECCA","葷",N
"85e13879cd70ee72532dc8823dbb503f","VIRGINIA","素",N
"48403a8ade71205cf92c1820deb7a962","KATHLEEN","葷",N
"e041d7afabeb71d69ad6bdac96d95575","PAMELA","素",N
"de0881a5824b9dba0925e5fdf15bf6bd","MARTHA","葷",N
"4aa7cdc891898e1c74a810448f59102c","DEBRA","葷",N
"ce41ae89b2ad073c6321bce05d563885","AMANDA","素",N
"2d4acd203b335e400ef36ed4d34ee2e2","STEPHANIE","葷",N
"e7f64b31340199985ee6803f8ab3b39e","CAROLYN","素",N
"18eac5a3946862b8cd34e2d37c229b3d","CHRISTINE","葷",N
"5382f8e7718f94736d850482e7ae8316","MARIE","葷",N
"e64d153fa408cb4e74ea0bff3a7b4d2e","JANET","素",N
"fc9db41221ac1b7403d185d58a44888e","CATHERINE","葷",N
"b7edc7b7341bb77e611d8f1d0a643819","FRANCES","葷",N
"c4f9bde7cdb2099961cce496a2f7b0a8","ANN","素",N
"c33c66ae4a39134b348dc4b619dc66e4","JOYCE","葷",N
"1c75cd1c124e2ede9aefb8b45a89adee","DIANE","素",N
"df779a8bb35387d8792c8823b30ce9ce","ALICE","葷",N
"36186f7d89d81e4961742ebeaa669314","JULIE","葷",N
"9b7391abcc2384f7836f47bde388a961","HEATHER","素",N
"3eb973079e7416b20a852ef96ebca612","TERESA","葷",N
"9d869b8db3b79add3092642f2262f22a","DORIS","素",N
"3f828284bb06d720cc8fede98db56bc6","GLORIA","葷",N
"d56eabaf6b0709ff718cd5977b787a8b","EVELYN","葷",N
"069b6e3c73e749684a7c34be84ecc547","JEAN","素",N
22 changes: 22 additions & 0 deletions worker/controller/attendee.ts
Original file line number Diff line number Diff line change
@@ -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('/attendees')
dannyh79 marked this conversation as resolved.
Show resolved Hide resolved
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)
}
}
1 change: 1 addition & 0 deletions worker/controller/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './announcement'
export * from './attendee'
export * from './landing'
export * from './status'
export * from './use'
Expand Down
Loading