-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #42
- Loading branch information
Showing
9 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# node-fetch-server HTTP/2 Example | ||
|
||
This is an example of building a http/2 server for Node.js using [the built-in `http2` module](https://nodejs.org/api/http2.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "node-fetch-server-http2-example", | ||
"private": true, | ||
"type": "module", | ||
"dependencies": { | ||
"@mjackson/node-fetch-server": "workspace:^" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIICpDCCAYwCCQDont9/q43GLTANBgkqhkiG9w0BAQsFADAUMRIwEAYDVQQDDAls | ||
b2NhbGhvc3QwHhcNMjUwMjA2MTkyMjU5WhcNMjYwMjA2MTkyMjU5WjAUMRIwEAYD | ||
VQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDX | ||
z69g6TBkbdv0TMeTL3jRLgdiSoTyqjcjLEakgEfPDtS0vLadkrqiTipx5do6CpyB | ||
0vMqrYVgFnnUKykJuTPh5pFIdTFbAKkv3YcyVMRfzt5eMLRFQ5iFbmbzme7BksaZ | ||
D6b0ahwnNPvRGX/Kz362wQ10nK4YP7JCXbc0Ybxvdfq5o8L0uoOjW5K+8JULVLmc | ||
imeXA8NLe8ui/flvBgc/P4qt5SVh0S+/FjTEa12DCzxkvaOmWKqpHjzUMg0aKkrV | ||
Q22hjaEdkgcKomqC/4I3de6bGr828yJltXxTp80/8TaM4U7xPi8hvUfOW+wLPUK9 | ||
ODJ+XtQu1LhtQwwe1a0RAgMBAAEwDQYJKoZIhvcNAQELBQADggEBADsHhsAveJ7N | ||
LOS/J8+y5/KGphlW0/bZzsJGCkm9YMFfPW6U3Ac85X67oahzd7kPI5n2z867dVXO | ||
Ix60enYF3xf2IzcL/FVSL+dDW6JKIp6lB+qdlA7EeN3Segx+NV/fErHUZmL5WmBN | ||
hNlOdEx06uo6Pp21+RyktDMFKBbpDbPrWHziNWJz0mT6SA1RMT8ElWxKXalO6XFT | ||
yJCM/iwpm4SrTZ11j8Nszcv730DrMr/hF+uO4d2N4FzV1NAKv66JpXnzPC1jcCFs | ||
Js7880NtdEdBVadp8gB5Cmu7I6ZcNKe24x1nRNtyddQkgUllKOoIGobrHk02l0PV | ||
0gnz6agIzfQ= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-----BEGIN CERTIFICATE REQUEST----- | ||
MIICWTCCAUECAQAwFDESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0B | ||
AQEFAAOCAQ8AMIIBCgKCAQEA18+vYOkwZG3b9EzHky940S4HYkqE8qo3IyxGpIBH | ||
zw7UtLy2nZK6ok4qceXaOgqcgdLzKq2FYBZ51CspCbkz4eaRSHUxWwCpL92HMlTE | ||
X87eXjC0RUOYhW5m85nuwZLGmQ+m9GocJzT70Rl/ys9+tsENdJyuGD+yQl23NGG8 | ||
b3X6uaPC9LqDo1uSvvCVC1S5nIpnlwPDS3vLov35bwYHPz+KreUlYdEvvxY0xGtd | ||
gws8ZL2jpliqqR481DINGipK1UNtoY2hHZIHCqJqgv+CN3Xumxq/NvMiZbV8U6fN | ||
P/E2jOFO8T4vIb1HzlvsCz1CvTgyfl7ULtS4bUMMHtWtEQIDAQABoAAwDQYJKoZI | ||
hvcNAQELBQADggEBAMyfFv3WSqg/X6RmrIZjuFdZ6fnV8Gd5twFuzGWcxcTaxQZx | ||
OwY7hKXXFsTRjx15T84wV7KcRK26RY9CJB+28zWp5r67/zLO1DkeZ+DuDjyazLPD | ||
iPMmpOhzK9dsu3ymhRjlQcKtUHfK5x/hlSvKaL8LYhEMY8G16ST8GQxoNAR+ax6t | ||
zq+wS7WccS7kKXr4uJf0H0KL3CqkmzLDlyiV/4f2UGQPk2riYihPuaikb5tLftUv | ||
cDsLwa4YOU6shdKa6Z0yq2oMjRYzAS79/gF22oxs5pK0Fzf5geQGjbzqd/CPrvWM | ||
M0IMtej9xpq+CfQv/pxAxmLEMW4WCnnqFwCN/xI= | ||
-----END CERTIFICATE REQUEST----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as http2 from 'node:http2'; | ||
import * as fs from 'node:fs'; | ||
import * as path from 'node:path'; | ||
import { createRequestListener } from '@mjackson/node-fetch-server'; | ||
|
||
const __dirname = path.dirname(new URL(import.meta.url).pathname); | ||
const PORT = 3000; | ||
|
||
let options = { | ||
key: fs.readFileSync(path.join(__dirname, 'server.key')), | ||
cert: fs.readFileSync(path.join(__dirname, 'server.crt')), | ||
}; | ||
|
||
let server = http2.createSecureServer(options); | ||
|
||
server.on( | ||
'request', | ||
createRequestListener((request) => { | ||
let url = new URL(request.url); | ||
|
||
if (url.pathname === '/') { | ||
return new Response('Hello HTTP/2!', { | ||
headers: { 'content-type': 'text/plain' }, | ||
}); | ||
} | ||
|
||
return new Response('Not Found', { status: 404 }); | ||
}), | ||
); | ||
|
||
server.on('error', (err) => { | ||
console.error('Server error:', err); | ||
}); | ||
|
||
server.listen(PORT, () => { | ||
console.log(`Server running at https://localhost:${PORT}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEowIBAAKCAQEA18+vYOkwZG3b9EzHky940S4HYkqE8qo3IyxGpIBHzw7UtLy2 | ||
nZK6ok4qceXaOgqcgdLzKq2FYBZ51CspCbkz4eaRSHUxWwCpL92HMlTEX87eXjC0 | ||
RUOYhW5m85nuwZLGmQ+m9GocJzT70Rl/ys9+tsENdJyuGD+yQl23NGG8b3X6uaPC | ||
9LqDo1uSvvCVC1S5nIpnlwPDS3vLov35bwYHPz+KreUlYdEvvxY0xGtdgws8ZL2j | ||
pliqqR481DINGipK1UNtoY2hHZIHCqJqgv+CN3Xumxq/NvMiZbV8U6fNP/E2jOFO | ||
8T4vIb1HzlvsCz1CvTgyfl7ULtS4bUMMHtWtEQIDAQABAoIBAGlbyDgcv/ZXt+lF | ||
zq0poOcmfI5c6Rj7Rp3SUM6gne4VRHzUIKc+6gSw+oHOgEKTyaKL1RFB03p8no+Z | ||
XpiTpSOlB8qDBEx0PyTSFt3YimJnwSHkzy19eamyo2pL/UbdnD0/aferEgGGGWYU | ||
99GQiUE5cJM8prXJ6wIBdJ6LFI6o+fNWjWAQeg6wEuA3MbfvQ4uZo8WvknVaJLqa | ||
AYMPK/V1bT9/hmaLFfDiLMrD92ZC+mJqgEvsLrU64mQmASa7Zfh9v6sqqS6h4vjZ | ||
fmJfQjG1+g1rCkE2kHEYKmziz3A0A5FUjWwny3RSt9lbIJh2E0vcgYtbF3abUCIe | ||
aQOQkP0CgYEA7MLq430P+Arn2xFPX8Y7XeQftv++qBsLZeq4lSV6ru1/mG68xFrm | ||
fqXI/xi3lyfbezpG0BFQGqVFB1f70IMGKcM7Ph1l5mI4OWcpqzcKi8UqGRzeFJ9Z | ||
NB7HWrU8h2dl/d5yRF4EmYj2RrBxoZdjN0H+3yL/TotcTuPPPbDKeRMCgYEA6Vj3 | ||
Kjnn3avIMK/UWkREXoGCvRQH2wD4h6vQs1ro2PNMyWB+JS1XxucJbPfDmZhqxkyt | ||
rWehadRrmlMfTX27llRjeoVH3h54QE58lgLme+Ak3qjNiiUlFVFiCpEaYrba3iDk | ||
A3jqQ1naqXyP6sbiItRZ96v05hiWIYe8WkaiCcsCgYAUziAT84Z2toafUosWEHZh | ||
Ds3Wp+yaGx5KS3EC8jMwsgAXZgvCeXZtxKW//O0NJFx+HKXiXNMcNE+3kHy5Wvos | ||
q1JGaBDvSMxGBxG7UO/lTmMfp9DAISyWjunXx7tU7rogr+58oYJn94gkuBaUK5h1 | ||
X6BE/W9P+KEY8Z3hfuqb7wKBgHGDhtEy1BmgvET68/lpZjz3Eat7OAsQoNYW/fKS | ||
Ed2gFcWMvDDHqwCmWY55xNxOKfsHSCGn3PzHigTL1Nl0hbGuoanzdi+WcPcPd0ne | ||
ZVLzidwLD9nZEf4Z1fC//67vtu8B3wnVY1iaOGXko3oZf95joNR8ASmB4l6zUiw0 | ||
WhUbAoGBAJIAzNQMMIF3fSUL4CnhTaWuo6UNUvQjXiSfx9opzWLfMWgGqoJ1RqEF | ||
HTL3jLQQfypqy6E0LtVRMhXJL/J1dY46ZJmkYxosDyfi1Om1wmKV4mbUGoIKiMFd | ||
1uOjZjUX3/XGA5rt1pdQxdwbauDgrPorQkKJFFWbCYZ9YCAxGxP9 | ||
-----END RSA PRIVATE KEY----- |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters