Skip to main content

Listen

Listen the server.

...// some codeapp.listen(3000);

Using Callback#

...// some codeconst callback = (err, opts) => {    if (err) console.log(err);    console.log("Running on server " + opts?.port);}app.listen(3000, callback);

Using Object Option#

...// some codeapp.listen({ port: 3000, hostname: 'localhost' }, callback);

Using Https#

...// some codeapp.listen({     port: 443,    certFile: "./path/to/localhost.crt",    keyFile: "./path/to/localhost.key",}, callback);

Using HTTP/2#

...// some codeapp.listen({     port: 443,    certFile: "./path/to/localhost.crt",    keyFile: "./path/to/localhost.key",    alpnProtocols: ["h2", "http/1.1"]}, callback);