MCPcopy Index your code
hub / github.com/web-push-libs/web-push / startServer

Function startServer

test/testSendNotification.js:77–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75 const vapidKeys = require('../src/vapid-helper').generateVAPIDKeys();
76
77 function startServer() {
78 const options = {
79 key: pem,
80 cert: pem
81 };
82
83 server = https.createServer(options, function(req, res) {
84 requestBody = Buffer.alloc(0);
85
86 req.on('data', function(chunk) {
87 requestBody = Buffer.concat([requestBody, chunk]);
88 });
89
90 req.on('end', function() {
91 requestDetails = req;
92
93 if (req.url.indexOf('statusCode=404') !== -1) {
94 res.writeHead(404);
95 res.end();
96 } else {
97 res.writeHead(201);
98 res.end('ok');
99 }
100 });
101 });
102
103 portfinder.getPort(function(err, port) {
104 if (err) {
105 serverPort = 50005;
106 } else {
107 serverPort = port;
108 }
109
110 server.listen(serverPort);
111 });
112
113 return new Promise(function(resolve) {
114 server.on('listening', resolve);
115 });
116 }
117
118 function closeServer() {
119 serverPort = null;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected