Mise en place du serveur de base
This commit is contained in:
13
src/core/app.ts
Normal file
13
src/core/app.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import Fastify from 'fastify'
|
||||
|
||||
export async function buildApp() {
|
||||
const app = Fastify({
|
||||
logger: true
|
||||
})
|
||||
|
||||
app.get('/', async () => {
|
||||
return { status: 'ok' }
|
||||
})
|
||||
|
||||
return app
|
||||
}
|
||||
15
src/core/server.ts
Normal file
15
src/core/server.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { buildApp } from './app'
|
||||
|
||||
const start = async () => {
|
||||
const app = await buildApp()
|
||||
|
||||
try {
|
||||
await app.listen({ port: 1234, host: '0.0.0.0' })
|
||||
console.log('Server running on http://localhost:1234')
|
||||
} catch (err) {
|
||||
app.log.error(err)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
start()
|
||||
Reference in New Issue
Block a user