-
Hi
The above works great on both my computer and when uploading it to the server, without the need to change anything, How can I do it using fastify? I did the following:
but I need the https section to conditionally be added depending on the existence of the pem files. I'm using typescript so I tried to add it only if the file exists and then creating the instance but something with the types got messy. Please advice. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Conditionally build your options object? |
Beta Was this translation helpful? Give feedback.
-
So for now I did the following
And I wonder if this is how it should be done or whether there's a better/cleaner way. |
Beta Was this translation helpful? Give feedback.
-
const baseConfig = {
logger: true
}
const listenConfig = {
host: '127.0.0.1',
port: 8080
}
if (serveHttps === true) {
baseConfig.https = { /* stuff */}
listenConfig.port = 8443
}
const server = fastify(baseConfig)
server.listen(listenConfig) |
Beta Was this translation helpful? Give feedback.
Is this a coding chellange?