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

Commit

Permalink
Feature: Configure URL prefix for the endpoints via .env
Browse files Browse the repository at this point in the history
  • Loading branch information
mischah committed Mar 9, 2016
1 parent 4c5c3b1 commit 081ec67
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .env
Expand Up @@ -7,3 +7,7 @@ SERVER_PORT=8081

# Port for running the tests
TEST_PORT=9090

# URL Prefix for the endpoints
# eg. http://localhost:8081/api/foo
API_PREFIX=/api
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -115,7 +115,7 @@ The configuration object in Detail:

## Configuration

The app needs to have a config file named `.env` with the following content:
The main config is handled via a file named `.env` with the following content:

```dosini
# NODE_ENV
Expand All @@ -127,6 +127,11 @@ SERVER_PORT=8081

# Port for running the tests
TEST_PORT=9090

# URL Prefix for the endpoints
# eg. http://localhost:8081/api/foo
API_PREFIX=/api

```


Expand Down
1 change: 1 addition & 0 deletions config.js
Expand Up @@ -12,6 +12,7 @@ const config = {
$meta: 'General project wide config.',
projectName: 'http-fake-backend',
env: process.env.NODE_ENV,
apiUrlPrefix: process.env.API_PREFIX,
port: {
web: {
$filter: 'env',
Expand Down
3 changes: 2 additions & 1 deletion server/api/setup/setup.js
@@ -1,11 +1,12 @@
'use strict';

const Boom = require('boom');
const Config = require('../../../config');

module.exports = function (settings) {

const exportEndpoint = {};
const path = '/api/' + settings.name;
const path = Config.get('/apiUrlPrefix') + '/' + settings.name;
const urls = settings.urls;

exportEndpoint.register = function (server, options, next) {
Expand Down

0 comments on commit 081ec67

Please sign in to comment.