Skip to content

Commit

Permalink
docs(recipes): audit servers with Deno (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia authored Mar 21, 2023
1 parent b1f04a7 commit e750bc0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,36 @@ for (const audit of serverAudits({

</details>

<details id="audit-deno">
<summary><a href="#audit-deno">🔗</a> Audit for servers usage in <a href="https://deno.land">Deno</a> environment</summary>

```ts
import { serverAudits } from 'npm:graphql-http';

for (const audit of serverAudits({
url: 'http://localhost:4000/graphql',
fetchFn: fetch,
})) {
Deno.test(audit.name, async () => {
const result = await audit.fn();
if (result.status === 'error') {
throw result.reason;
}
if (result.status === 'warn') {
console.warn(result.reason); // or throw if you want full compliance (warnings are not requirements)
}
// Avoid leaking resources
if ('body' in result && result.body instanceof ReadableStream) {
await result.body.cancel();
}
});
}
```

Put the above contents in a file and run it with `deno test --allow-net`.

</details>

## Only [GraphQL over HTTP](https://graphql.github.io/graphql-over-http/)

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).
Expand Down

0 comments on commit e750bc0

Please sign in to comment.