Skip to content

Commit

Permalink
docs(get-started): use secure http2 server
Browse files Browse the repository at this point in the history
Closes #98
  • Loading branch information
enisdenjo committed Apr 22, 2024
1 parent 92b1658 commit b20487f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions website/src/pages/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,18 @@ import { schema } from './previous-step';
const handler = createHandler({ schema });

// Create an HTTP/2 server using the handler on `/graphql/stream`
const server = http2.createServer((req, res) => {
if (req.url.startsWith('/graphql/stream')) {
return handler(req, res);
}
res.writeHead(404).end();
});
const server = http2.createSecureServer(
{
key: fs.readFileSync('localhost-privkey.pem'),
cert: fs.readFileSync('localhost-cert.pem'),
},
(req, res) => {
if (req.url.startsWith('/graphql/stream')) {
return handler(req, res);
}
return res.writeHead(404).end();
},
);

server.listen(4000);
console.log('Listening to port 4000');
Expand Down

0 comments on commit b20487f

Please sign in to comment.