forked from vercel/micro
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vercel#369 Update examples to work with new api
- Loading branch information
1 parent
0c3f3ca
commit 68411e5
Showing
10 changed files
with
71 additions
and
12 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
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
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 |
---|---|---|
|
@@ -9,6 +9,6 @@ | |
"license": "ISC", | ||
"dependencies": { | ||
"micro": "latest", | ||
"socket.io": "1.7.3" | ||
"socket.io": "2.2.0" | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
const https = require('https'); | ||
const {run, send} = require('micro'); | ||
const { listener, res } = require('micro'); | ||
|
||
const {key, cert, passphrase} = require('openssl-self-signed-certificate'); | ||
const { key, cert, passphrase } = require('openssl-self-signed-certificate'); | ||
|
||
const PORT = process.env.PORT || 3443; | ||
|
||
const options = {key, cert, passphrase}; | ||
const options = { key, cert, passphrase }; | ||
|
||
const microHttps = fn => https.createServer(options, (req, res) => run(req, res, fn)); | ||
const microHttps = fn => https.createServer(options, listener(fn)); | ||
|
||
const server = microHttps(async (req, res) => { | ||
send(res, 200, {encrypted: req.client.encrypted}); | ||
}); | ||
const handler = req => res({ encrypted: req.client.encrypted }, 200); | ||
|
||
const server = microHttps(handler); | ||
|
||
server.listen(PORT); | ||
console.log(`Listening on https://localhost:${PORT}`); |