mirror of
https://github.com/coollabsio/coolify-examples.git
synced 2026-02-18 13:28:57 +00:00
init 🌮
This commit is contained in:
28
nodejs/index.js
Normal file
28
nodejs/index.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const fastify = require('fastify')({ logger: {level: "error"}, trustProxy: true })
|
||||
const PORT = process.env.PORT || 3000
|
||||
fastify.register(require('@fastify/cors'))
|
||||
|
||||
fastify.get('/', function (req, reply) {
|
||||
return { hello: "from nodejs" }
|
||||
})
|
||||
fastify.get('/env', function (req, reply) {
|
||||
return { env: process.env.NODE_ENV }
|
||||
})
|
||||
|
||||
fastify.get('/health', function (req, reply) {
|
||||
return 'OK'
|
||||
})
|
||||
|
||||
const start = async () => {
|
||||
try {
|
||||
await fastify.listen({
|
||||
host: '0.0.0.0',
|
||||
port: PORT
|
||||
})
|
||||
console.log('Server listening on http://localhost:3000');
|
||||
} catch (err) {
|
||||
fastify.log.error(err)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
start()
|
||||
Reference in New Issue
Block a user