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 is in the init.js of our custom module. I checked that this function is being called. | |
// There isn't any error. But the tables are not created. | |
var ensureSchema = function(callback) { | |
Cassandra.createColumnFamilies({ | |
'PersonalJob': 'CREATE TABLE "PersonalJob" ("revisionId" text PRIMARY KEY, "contentId" text, "jobId" text, "userId" text, "caseName" text, "xmlName" text, "fileName" text, "status" text, "units" int, "maxDuration" int, "result" text, "cost" text)', | |
'PersonalJobRevision': 'CREATE TABLE "PersonalJobRevision" ("jobId" text PRIMARY KEY, "revisionId" text)' | |
}, callback); | |
}; |
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
function endpoint(service, version = '') { | |
let protocol | |
let domain | |
if (service === 'webclient') { | |
protocol = __CLIENT_PROTOCOL__ | |
domain = `${__ENV__}-${service}.${__DOMAIN__}` | |
if (__SERVER__) { | |
protocol = 'http' | |
} else if (__ENV__ === 'production') { |
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
import endpoint from 'config/endpoint' | |
describe('endpoint.js', () => { | |
global.__DOMAIN__ = 'gousto.local' | |
let service | |
describe('when the service is "webclient"', () => { | |
beforeEach(() => { | |
service = 'webclient' | |
}) |
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
$ jest src/config/__tests__/endpoint.test.js | |
PASS src/config/__tests__/endpoint.test.js | |
endpoint.js | |
when the service is "webclient" | |
and being in the server side | |
✓ an http address with the corresponding ENV, SERVICE and DOMAIN is returned (3ms) | |
and not being in the server side | |
and the environment is production | |
✓ an https address with "www" and without the service, but with the DOMAIN is returned | |
and the environment is not production |
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
-------------------|----------|----------|----------|----------|-------------------| | |
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | | |
-------------------|----------|----------|----------|----------|-------------------| | |
... | ... | ... | ... | ... | ...| | |
endpoint.js | 100 | 100 | 100 | 100 | | | |
... | ... | ... | ... | ... | ...| | |
-------------------|----------|----------|----------|----------|-------------------| | |
Test Suites: 1 passed, 1 total | |
Tests: 12 passed, 12 total |
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
... | |
function endpoint(service, version = '') { | |
const protocol = getProtocol(service, __SERVER__, __ENV__) | |
const subdomain = getSubdomain(service, __SERVER__, __ENV__) | |
const path = getPath(service, __SERVER__, __ENV__, version) | |
const port = getPort(service, __ENV__, __CLIENT__) | |
return `${protocol}://${subdomain}.${__DOMAIN__}${port}${path}` | |
} |
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
const getProtocol = (service, isServerSide, environment) => { | |
if (service === 'webclient') { | |
if (isServerSide) { | |
return 'http' | |
} | |
return 'https' | |
} else { | |
if (environment === 'local') { | |
return 'http' |
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
Service is Webclient | Server Side | Env is Local | Returns | |
---|---|---|---|---|
TRUE | TRUE | - | http | |
TRUE | FALSE | - | https | |
FALSE | - | TRUE | http | |
FALSE | TRUE | FALSE | http | |
FALSE | FALSE | FALSE | https |
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
Service is Webclient | Server Side | Env is Local | Returns | |
---|---|---|---|---|
TRUE | TRUE | TRUE | http | |
TRUE | TRUE | FALSE | http | |
TRUE | FALSE | TRUE | https | |
TRUE | FALSE | FALSE | https | |
FALSE | TRUE | TRUE | http | |
FALSE | FALSE | TRUE | http | |
FALSE | TRUE | FALSE | http | |
FALSE | FALSE | FALSE | https |
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
const getProtocol = (service, isServerSide, environment) => { | |
if (isServerSide) { | |
return 'http' | |
} | |
if (service === 'webclient') { | |
return 'https' | |
} | |
if (service !== 'webclient' && environment !== 'local') { |
OlderNewer