Skip to content

Commit 230e084

Browse files
committed
fix(connect): require destroy confirmation to be strictly true
1 parent ed180cd commit 230e084

File tree

10 files changed

+15
-5
lines changed

10 files changed

+15
-5
lines changed

packages/connect/deno/services/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ export const query = (pattern = '*') => (h: HyperRequestFunction) =>
4747
export const create = () => (hyper: HyperRequestFunction) => hyper({ service, method: Method.PUT })
4848

4949
export const destroy = (confirm?: boolean) => (hyper: HyperRequestFunction) =>
50-
confirm
50+
confirm === true
5151
? hyper({ service, method: Method.DELETE })
5252
: Promise.reject({ ok: false, msg: 'request not confirmed!' })

packages/connect/deno/services/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ export const index = (
6666
export const create = () => (hyper: HyperRequestFunction) => hyper({ service, method: Method.PUT })
6767

6868
export const destroy = (confirm?: boolean) => (hyper: HyperRequestFunction) =>
69-
confirm
69+
confirm === true
7070
? hyper({ service, method: Method.DELETE })
7171
: Promise.reject({ ok: false, msg: 'request not confirmed!' })

packages/connect/deno/services/queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ export const create = (target: string, secret?: string) => (hyper: HyperRequestF
1515
hyper({ service, method: Method.PUT, body: { target, secret } })
1616

1717
export const destroy = (confirm?: boolean) => (hyper: HyperRequestFunction) =>
18-
confirm
18+
confirm === true
1919
? hyper({ service, method: Method.DELETE })
2020
: Promise.reject({ ok: false, msg: 'request not confirmed!' })

packages/connect/deno/services/search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ export const create = (fields: string[], storeFields?: string[]) => (hyper: Hype
3737
hyper({ service, method: Method.PUT, body: { fields, storeFields } })
3838

3939
export const destroy = (confirm?: boolean) => (hyper: HyperRequestFunction) =>
40-
confirm
40+
confirm === true
4141
? hyper({ service, method: Method.DELETE })
4242
: Promise.reject({ ok: false, msg: 'request not confirmed!' })

packages/connect/deno/services/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ export const remove = (name: string) => (h: HyperRequestFunction) =>
5959
export const create = () => (hyper: HyperRequestFunction) => hyper({ service, method: Method.PUT })
6060

6161
export const destroy = (confirm?: boolean) => (hyper: HyperRequestFunction) =>
62-
confirm
62+
confirm === true
6363
? hyper({ service, method: Method.DELETE })
6464
: Promise.reject({ ok: false, msg: 'request not confirmed!' })

packages/connect/deno/tests/cache.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,6 @@ test('cache.destroy', async () => {
106106
}
107107

108108
await destroy()(noConfirmRequest).catch(assert)
109+
// @ts-expect-error testing runtime checks
110+
await destroy('no-bool')(noConfirmRequest).catch(assert)
109111
})

packages/connect/deno/tests/data.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,6 @@ test('data.destroy', async () => {
164164
}
165165

166166
await destroy()(noConfirmRequest).catch(assert)
167+
// @ts-expect-error testing runtime checks
168+
await destroy('no-bool')(noConfirmRequest).catch(assert)
167169
})

packages/connect/deno/tests/queue.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,6 @@ test('queue.destroy', async () => {
100100
}
101101

102102
await destroy()(noConfirmRequest).catch(assert)
103+
// @ts-expect-error testing runtime checks
104+
await destroy('no-bool')(noConfirmRequest).catch(assert)
103105
})

packages/connect/deno/tests/search.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,6 @@ test('search.destroy', async () => {
137137
}
138138

139139
await destroy()(noConfirmRequest).catch(assert)
140+
// @ts-expect-error testing runtime checks
141+
await destroy('no-bool')(noConfirmRequest).catch(assert)
140142
})

packages/connect/deno/tests/storage.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,6 @@ test('storage.destroy', async () => {
130130
}
131131

132132
await destroy()(noConfirmRequest).catch(assert)
133+
// @ts-expect-error testing runtime checks
134+
await destroy('no-bool')(noConfirmRequest).catch(assert)
133135
})

0 commit comments

Comments
 (0)