Skip to content

Commit

Permalink
use esm and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed May 11, 2023
1 parent 2ae78d0 commit e38ed71
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/use/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ export interface Extra {
* the correct example being:
*
* ```ts
* import { serve } from "https://deno.land/std/http/mod.ts";
* import { serve } from 'https://deno.land/std/http/mod.ts';
* import {
* makeHandler,
* GRAPHQL_TRANSPORT_WS_PROTOCOL,
* } from "graphql-ws/lib/use/deno";
* import { schema } from "./my-schema.ts";
* } from 'https://esm.sh/graphql-ws/lib/use/deno';
* import { schema } from './my-schema.ts';
*
* const handler = makeHandler({ schema });
*
* serve(
* (req: Request) => {
* if (req.headers.get("upgrade") != "websocket") {
* if (req.headers.get('upgrade') != 'websocket') {
* return new Response(null, { status: 501 });
* }
* const { socket, response } = Deno.upgradeWebSocket(req, {
Expand All @@ -49,7 +49,7 @@ export interface Extra {
* handler(socket);
* return response;
* },
* { port: 4000 }
* { port: 4000 },
* );
* ```
*
Expand Down
28 changes: 28 additions & 0 deletions website/src/pages/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,34 @@ Bun.serve({
console.log('Listening to port 4000');
```

#### With [Deno](https://deno.com/runtime)

```ts
import { serve } from 'https://deno.land/std/http/mod.ts';
import {
makeHandler,
GRAPHQL_TRANSPORT_WS_PROTOCOL,
} from 'https://esm.sh/graphql-ws/lib/use/deno';
import { schema } from './previous-step.ts';

const handler = makeHandler({ schema });

serve(
(req: Request) => {
if (req.headers.get('upgrade') != 'websocket') {
return new Response(null, { status: 501 });
}
const { socket, response } = Deno.upgradeWebSocket(req, {
protocol: GRAPHQL_TRANSPORT_WS_PROTOCOL,
idleTimeout: 12_000,
});
handler(socket);
return response;
},
{ port: 4000 },
);
```

### Use the client

```ts
Expand Down

0 comments on commit e38ed71

Please sign in to comment.