Skip to content

Commit

Permalink
added api client and mock for purge deleted action
Browse files Browse the repository at this point in the history
  • Loading branch information
pricelessrabbit committed Jun 21, 2024
1 parent fbb8929 commit a448c78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions frontend/src/api/buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ function create(connectionId: string, bucket: BucketConfig, opt?: CallOptions):
return ajax.post(`connection/${connectionId}/kv`, bucket, opt)
}

/** PURGE DELETED keys from bucket */
function purgeDeleted(connectionId: string, bucketName: string, opt?: CallOptions): Promise<void> {
return ajax.post(`connection/${connectionId}/kv/${bucketName}/purge`, null, opt)
}


const api = {
index,
get,
remove,
create,
purgeDeleted
}
export default api
8 changes: 7 additions & 1 deletion frontend/src/mocks/ajax/handlers/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { bucketStateFromConfig } from '@/mocks/data/utils/bucket'
import { BucketConfig, BucketState } from '@/types/Bucket'
import { camelToSnake, snakeToCamel } from '@/utils/object'
import { rest } from 'msw'
import keyValueEntries_S from "../../data/kventries";



Expand Down Expand Up @@ -50,7 +51,7 @@ const handlers = [
// return res(
// ctx.status(400),
// ctx.json({
// error: "TITOLO ABBASTANZA LUNGO DA ESSERE PREOCCUPOANTE http:error:500 nats: API error: code=500 err_code=10052 description=max age needs to be = 100ms etc etc etc etc etc etc"
// error: "ERROR TITLE http:error:500 nats: API error: code=500 err_code=10052 description=max age needs to be = 100ms etc"
// }),
// )
return res(
Expand All @@ -59,6 +60,11 @@ const handlers = [
)
}),

rest.post('/api/connection/:cnnId/kv/:bucketName', async (req, res, ctx) => {
keyValueEntries_S.splice(0, keyValueEntries_S.length, ...keyValueEntries_S.filter((entry) => !entry.is_deleted))
return res(ctx.status(204))
})

]

export default handlers

0 comments on commit a448c78

Please sign in to comment.