feat: update backend src/index.ts with basic Fastify server
This commit is contained in:
+12
-8
@@ -1,15 +1,19 @@
|
||||
import app from './server.js';
|
||||
import fastify from 'fastify'
|
||||
|
||||
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
|
||||
const app = fastify({ logger: true })
|
||||
|
||||
app.get('/api/health', async (request, reply) => {
|
||||
return { status: 'OK' }
|
||||
})
|
||||
|
||||
const start = async () => {
|
||||
try {
|
||||
await app.listen({ port: PORT, host: '0.0.0.0' });
|
||||
console.log(`Server listening on port ${PORT}`);
|
||||
await app.listen({ port: 3001, host: '0.0.0.0' })
|
||||
console.log('Server listening on port 3001')
|
||||
} catch (err) {
|
||||
app.log.error(err);
|
||||
process.exit(1);
|
||||
app.log.error(err)
|
||||
process.exit(1)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
start();
|
||||
start()
|
||||
Reference in New Issue
Block a user