diff --git a/src/controllers/RunnerCardController.ts b/src/controllers/RunnerCardController.ts
index ae74e86..c611ef5 100644
--- a/src/controllers/RunnerCardController.ts
+++ b/src/controllers/RunnerCardController.ts
@@ -47,6 +47,21 @@ export class RunnerCardController {
return card.toResponse();
}
+ @Post('/bulk')
+ @Authorized("CARD:CREATE")
+ @ResponseSchema(ResponseEmpty, { statusCode: 200 })
+ @OpenAPI({ description: "Create blank cards in bulk.
Just provide the count as a query param and wait for the 200 response." })
+ async postBlancoBulk(@QueryParam("count") count: number) {
+ let createPromises = new Array();
+ for (let index = 0; index < count; index++) {
+ createPromises.push(this.cardRepository.save({ runner: null, enabled: true }))
+ }
+ await Promise.all(createPromises);
+ let response = new ResponseEmpty();
+ response.response = `Created ${count} new blanco cards.`
+ return response;
+ }
+
@Post()
@Authorized("CARD:CREATE")
@ResponseSchema(ResponseRunnerCard)
diff --git a/src/tests/cards/cards_add.spec.ts b/src/tests/cards/cards_add.spec.ts
index 10ee9d4..ef967af 100644
--- a/src/tests/cards/cards_add.spec.ts
+++ b/src/tests/cards/cards_add.spec.ts
@@ -148,4 +148,27 @@ describe('POST /api/cards successfully (with runner)', () => {
"responseType": "RUNNERCARD"
});
});
+});
+// ---------------
+describe('POST /api/cards/bulk successfully', () => {
+ it('creating a single new bulk card should return 200', async () => {
+ const res = await axios.post(base + '/api/cards/bulk?count=1', {}, axios_config);
+ expect(res.status).toEqual(200);
+ expect(res.headers['content-type']).toContain("application/json");
+ });
+ it('creating 50 new bulk card should return 200', async () => {
+ const res = await axios.post(base + '/api/cards/bulk?count=50', {}, axios_config);
+ expect(res.status).toEqual(200);
+ expect(res.headers['content-type']).toContain("application/json");
+ });
+ it('creating 250 new bulk card should return 200', async () => {
+ const res = await axios.post(base + '/api/cards/bulk?count=250', {}, axios_config);
+ expect(res.status).toEqual(200);
+ expect(res.headers['content-type']).toContain("application/json");
+ });
+ it('creating 2000 new bulk card should return 200', async () => {
+ const res = await axios.post(base + '/api/cards/bulk?count=2000', {}, axios_config);
+ expect(res.status).toEqual(200);
+ expect(res.headers['content-type']).toContain("application/json");
+ });
});
\ No newline at end of file