Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Commit

Permalink
Fix swagger host setting in order to add support for the live environ…
Browse files Browse the repository at this point in the history
…ment. (#35)
  • Loading branch information
alrik committed Jan 6, 2018
1 parent 8a176d4 commit e3ed890
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/openapi-v1.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = function({ version }) {
module.exports = function({ version, host }) {
const HANDLE_REGEX = '[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9]';
const SCOPE_REGEX = `@?${HANDLE_REGEX}`;

return {
swagger: '2.0',
basePath: '/api/v1',
host: "localhost:8080",
host,
info: {
title: 'The Release Notes API',
version: version,
Expand Down
4 changes: 3 additions & 1 deletion config/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const svgEmbed = require('../lib/svg-embed');

const APP_PATH = `${__dirname}/..`;
const env = process.env;
const APP_BASE_URL = env.BASE_URL || 'https://release-notes.com';
const APP_HOST = env.HOST || 'release-notes.com';
const APP_BASE_URL = env.BASE_URL || `https://${APP_HOST}`;

module.exports = {
app: {
Expand Down Expand Up @@ -109,6 +110,7 @@ module.exports = {

api: {
version: '0.0.0',
host: APP_HOST,
},

apiController: {
Expand Down
3 changes: 2 additions & 1 deletion services/ApiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ class ApiService extends Service {

bind(expressApp) {
const version = this.serviceConfig.get('version');
const host = this.serviceConfig.get('host');
const serviceManager = this.serviceManager;
const authTokenRepository = serviceManager.get('authTokenRepository');

expressOpenapi.initialize({
app: expressApp,
apiDoc: apiDocV1({ version }),
apiDoc: apiDocV1({ version, host }),
paths: './api/v1',
docsPath: '/api-spec',
exposeApiDocs: true,
Expand Down

0 comments on commit e3ed890

Please sign in to comment.