-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (43 loc) · 1.22 KB
/
index.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict'
const Fastify = require('fastify')
const fastifyMongo = require('@fastify/mongodb')
const fastifyOverview = require('fastify-overview')
const fastifyOverviewUi = require('fastify-overview-ui')
// const fp = require('fastify-plugin')
async function run () {
const app = Fastify({ logger: true, exposeHeadRoutes: false })
await app.register(fastifyOverview, { hideEmpty: true })
await app.register(fastifyOverviewUi)
app.decorate('config', function () {
})
app.register(function pluginOne (app, opts, next) {
next()
})
app.register(function pluginTwo (app, opts, next) {
// 2
app.decorate('utility', function () {
})
app.register(function pluginFour (app, opts, next) {
// 4
app.get('/hello', () => { })
app.register(function pluginFive (app, opts, next) {
app.decorate('utilityChild', function () {
})
next()
})
app.register(function pluginSix (app, opts, next) {
app.register(fastifyMongo, {
url: 'mongodb://localhost:27011fix'
})
next()
})
next()
})
next()
})
app.register(function pluginThree (app, opts, next) {
next()
})
await app.listen({ port: 8080 })
}
run()