- Changed create and update method. Headers+body instead of DTO

- Added token validation for `update` and `remove` operations to ensure it matches the record in the database.
- Ensured `name` and `author` from headers in `update` are validated against the existing record.
- Improved error handling for mismatched or missing tokens, returning appropriate HTTP status codes.
This commit is contained in:
oscargonzalezmoreno@gmail.com 2024-12-27 12:30:50 +01:00
parent c8ce6e7637
commit 121ccadf57
8 changed files with 328 additions and 151 deletions

View file

@ -87,7 +87,7 @@ describe('Rices API E2E', () => {
const updateResponse = await request(app.getHttpServer())
.put(`/rices/${slug}`)
.set('x-rices-token', token)
.set('x-zen-rices-token', token)
.field('name', 'Updated Rice')
.attach('file', path.join(__dirname, 'files', 'example_update.zenrice'))
.expect(200);
@ -116,7 +116,7 @@ describe('Rices API E2E', () => {
await request(app.getHttpServer())
.delete(`/rices/${slug}`)
.set('x-rices-token', token)
.set('x-zen-rices-token', token)
.expect(204);
const riceInDatabase = await supabaseService.getRiceBySlug(slug);