Skip to content

Commit e750bc0

Browse files
authored
docs(recipes): audit servers with Deno (#63)
1 parent b1f04a7 commit e750bc0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,36 @@ for (const audit of serverAudits({
736736

737737
</details>
738738

739+
<details id="audit-deno">
740+
<summary><a href="#audit-deno">🔗</a> Audit for servers usage in <a href="https://deno.land">Deno</a> environment</summary>
741+
742+
```ts
743+
import { serverAudits } from 'npm:graphql-http';
744+
745+
for (const audit of serverAudits({
746+
url: 'http://localhost:4000/graphql',
747+
fetchFn: fetch,
748+
})) {
749+
Deno.test(audit.name, async () => {
750+
const result = await audit.fn();
751+
if (result.status === 'error') {
752+
throw result.reason;
753+
}
754+
if (result.status === 'warn') {
755+
console.warn(result.reason); // or throw if you want full compliance (warnings are not requirements)
756+
}
757+
// Avoid leaking resources
758+
if ('body' in result && result.body instanceof ReadableStream) {
759+
await result.body.cancel();
760+
}
761+
});
762+
}
763+
```
764+
765+
Put the above contents in a file and run it with `deno test --allow-net`.
766+
767+
</details>
768+
739769
## Only [GraphQL over HTTP](https://graphql.github.io/graphql-over-http/)
740770

741771
This is the official [GraphQL over HTTP spec](https://graphql.github.io/graphql-over-http/) reference implementation and as such follows the specification strictly without any additional features (like file uploads, @stream/@defer directives and subscriptions).

0 commit comments

Comments
 (0)