-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.js
36 lines (30 loc) · 792 Bytes
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict'
const fastify = require('fastify')()
const fastifyPrettier = require('./src/index')
const chalk = require('chalk')
const defaults = { port: 3000 }
;(async () => {
await fastify.register(fastifyPrettier)
fastify.get('/', (req, reply) => {
const obj = {
blackLivesMatter: true,
favSinger: 'Ahmet Kaya',
visitedCities: ['Mardin', 'Diyarbakır', 'Rome', 'Amsterdam', 'Istanbul', 'Kotor', 'Mostar', 'Belgrade'],
pi: 3.14,
games: {
rdr2: 'completed',
gtfo: 'continues'
}
}
reply
.type('application/json')
.send(obj)
})
fastify.listen(defaults.port, () => {
console.log(
chalk.bgYellow(
chalk.black(`Fastify server is running on port: ${defaults.port}`)
)
)
})
})()