mirror of https://github.com/lukechilds/micro.git
Albin Ekblom
7 years ago
committed by
Leo Lamprecht
2 changed files with 34 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||
const https = require('https') |
|||
const { run, send } = require('micro') |
|||
|
|||
const cert = require('openssl-self-signed-certificate') |
|||
|
|||
const PORT = process.env.PORT || 3443 |
|||
|
|||
const options = { |
|||
key: cert.key, |
|||
cert: cert.cert, |
|||
passphrase: cert.passphrase |
|||
} |
|||
|
|||
const microHttps = fn => https.createServer(options, (req, res) => run(req, res, fn)) |
|||
|
|||
const server = microHttps(async (req, res) => { |
|||
send(res, 200, { encrypted: req.client.encrypted }) |
|||
}) |
|||
|
|||
server.listen(PORT) |
|||
console.log(`Listening on https://localhost:${PORT}`) |
@ -0,0 +1,13 @@ |
|||
{ |
|||
"name": "with-https", |
|||
"version": "1.0.0", |
|||
"main": "index.js", |
|||
"license": "MIT", |
|||
"scripts": { |
|||
"start": "node ." |
|||
}, |
|||
"dependencies": { |
|||
"micro": "latest", |
|||
"openssl-self-signed-certificate": "^1.1.6" |
|||
} |
|||
} |
Loading…
Reference in new issue