Skip to content
Steven A edited this page Apr 17, 2017 · 3 revisions

This API supports HTTP and HTTPS.

You don't have to set up things twice. Simply pass a key and certificate property, and the API will handle that for you. Once configured, your API-instance will listen to your specified HTTP and HTTPS port. Port 443 is the default port for HTTPS. If you wish to use any other port, simply pass a second argument to connect().

api = new API({
    restify: {
        key: readFileSync('localhost.key'),
        certificate: readFileSync('localhost.cert')
    }
})

api.listen(80) #API is going to listen on HTTP(80) and HTTPS(443)

# OR

api.listen(80, 8443) #API is going to listen on HTTP(80) and HTTPS(8443)

If no key/certificate property is available, your API-instance won't listen to HTTPS.

Addons

Clone this wiki locally