From a36720a54d56954aa86a654d0214306340611b80 Mon Sep 17 00:00:00 2001 From: Devin Ivy Date: Sun, 11 Apr 2021 23:24:17 -0400 Subject: [PATCH] (flavor) swagger v3.0.0 --- package.json | 7 +++++-- server/manifest.js | 3 +++ server/plugins/swagger.js | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 server/plugins/swagger.js diff --git a/package.json b/package.json index 3d39189..7bfcea2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "scripts": { "start": "node server", - "test": "lab -a @hapi/code -L", + "test": "lab -a @hapi/code -I \"__core-js_shared__,CSS,regeneratorRuntime,core\" -L", "lint": "eslint ." }, "dependencies": { @@ -25,7 +25,9 @@ "@hapi/eslint-plugin-hapi": "4.x.x", "@hapi/glue": "8.x.x", "@hapi/hapi": "20.x.x", + "@hapi/inert": "6.x.x", "@hapi/lab": "24.x.x", + "@hapi/vision": "6.x.x", "@hapipal/confidence": "6.x.x", "@hapipal/hpal": "3.x.x", "@hapipal/hpal-debug": "2.x.x", @@ -33,6 +35,7 @@ "babel-eslint": "10.x.x", "dotenv": "8.x.x", "eslint": "7.x.x", - "exiting": "6.x.x" + "exiting": "6.x.x", + "hapi-swagger": "14.x.x" } } diff --git a/server/manifest.js b/server/manifest.js index ffb9f26..126d373 100644 --- a/server/manifest.js +++ b/server/manifest.js @@ -33,6 +33,9 @@ module.exports = new Confidence.Store({ plugin: '../lib', // Main plugin options: {} }, + { + plugin: './plugins/swagger' + }, { plugin: { $filter: 'NODE_ENV', diff --git a/server/plugins/swagger.js b/server/plugins/swagger.js new file mode 100644 index 0000000..cf64e1e --- /dev/null +++ b/server/plugins/swagger.js @@ -0,0 +1,25 @@ +'use strict'; + +const Inert = require('@hapi/inert'); +const Vision = require('@hapi/vision'); +const HapiSwagger = require('hapi-swagger'); +const Package = require('../../package.json'); + +module.exports = { + name: 'app-swagger', + async register(server) { + + await server.register([ + Inert, + Vision, + { + plugin: HapiSwagger, + options: { + info: { + version: Package.version + } + } + } + ]); + } +};