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 () => {
|
const start = async () => {
|
||||||
try {
|
try {
|
||||||
await app.listen({ port: PORT, host: '0.0.0.0' });
|
await app.listen({ port: 3001, host: '0.0.0.0' })
|
||||||
console.log(`Server listening on port ${PORT}`);
|
console.log('Server listening on port 3001')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
app.log.error(err);
|
app.log.error(err)
|
||||||
process.exit(1);
|
process.exit(1)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
start();
|
start()
|
||||||
Reference in New Issue
Block a user