-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.js
29 lines (24 loc) · 923 Bytes
/
sample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('fs');
const path = require('path');
const { createServer } = require('../src');
function serverOptsFactory() {
return {
key: fs.readFileSync(path.join(__dirname, '../test/keys/good_privkey.pem')),
cert: fs.readFileSync(path.join(__dirname, '../test/keys/good_cert.pem')),
ca: fs.readFileSync(path.join(__dirname, '../test/keys/good_chain.pem'))
};
}
const KeyPaths = [
path.join(__dirname, '../test/keys/good_cert.pem'),
path.join(__dirname, '../test//keys/good_chain.pem'),
path.join(__dirname, '../test/keys/good_privkey.pem')
];
const server = createServer(serverOptsFactory, KeyPaths, (req, res) => {
// eslint-disable-next-line no-console
console.log('connect');
res.writeHead(200);
res.write('Hello World!\n');
res.end('Goodbye World!\n');
}, 20);
// eslint-disable-next-line no-console
server.listen(9999, () => console.log('Server up: ', server.address()));