This repository has been archived by the owner on May 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cde7b4
commit d3113b3
Showing
6 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { getApiTokenName, getMissingEnvironmentTokens } from './config.js'; | ||
|
||
describe('config', () => { | ||
describe('getApiTokenName', () => { | ||
it('should return "fakeWebMynaTokenName" if api.name is not a string', () => { | ||
const testGetApiTokenName = api => expect(getApiTokenName(api)).toEqual('fakeWebMynaTokenName'); | ||
testGetApiTokenName({ name: null }); | ||
testGetApiTokenName({ name: undefined }); | ||
testGetApiTokenName({ name: 345 }); | ||
testGetApiTokenName({ name: { foo: 'bar' } }); | ||
testGetApiTokenName({ name: '' }); | ||
testGetApiTokenName({}); | ||
}); | ||
|
||
it('should return a well formated token name', () => { | ||
expect(getApiTokenName({ name: 'rick-and-morty' })).toEqual('RICK_AND_MORTY_TOKEN'); | ||
}); | ||
}); | ||
|
||
describe('getMissingEnvironmentTokens', () => { | ||
it('should return an array of missing token in precess.env', () => { | ||
const apis = [ | ||
{ name: 'api-1', requiresAuthentication: false }, | ||
{ name: 'api-2', requiresAuthentication: true }, | ||
{ name: 'api-3', requiresAuthentication: true }, | ||
]; | ||
const processEnv = {}; | ||
processEnv['API_2_TOKEN'] = 'foo'; | ||
expect(getMissingEnvironmentTokens(apis, processEnv)).toEqual(['API_3_TOKEN']); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import signale from 'signale'; | ||
|
||
import { app } from './app.js'; | ||
import config from './config.js'; | ||
import * as appJs from './app.js'; | ||
import config, { getMissingEnvironmentTokens } from './config.js'; | ||
|
||
app.listen(config.proxyPort, () => { | ||
signale.info(`Web Myna is starded on port ${config.proxyPort} in environment ${config.env}`); | ||
}); | ||
const missingTokens = getMissingEnvironmentTokens(); | ||
|
||
if (missingTokens.length) { | ||
signale.error('IL MANQUE DES TOKENS', missingTokens); | ||
} else { | ||
appJs.app.listen(config.proxyPort, () => { | ||
signale.info(`Web Myna is starded on port ${config.proxyPort} in environment ${config.env}`); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters