feat(credentials): allow setting of space id and tokens via query string

This commit is contained in:
Benedikt Rötsch
2017-09-29 10:50:31 +02:00
committed by Benedikt Rötsch
parent 9806d494dc
commit 926b59aaaa
2 changed files with 26 additions and 7 deletions

View File

@@ -3,9 +3,21 @@ const { createClient } = require('contentful')
let cdaClient = null
let cpaClient = null
exports.initClient = (config = {space: process.env.CF_SPACE, accessToken: process.env.CF_ACCESS_TOKEN}) => {
cdaClient = createClient(config)
cpaClient = createClient({space: process.env.CF_SPACE, accessToken: process.env.CF_PREVIEW_ACCESS_TOKEN, host: 'preview.contentful.com'})
exports.initClient = (options) => {
const config = options || {
space: process.env.CF_SPACE,
cda: process.env.CF_ACCESS_TOKEN,
cpa: process.env.CF_PREVIEW_ACCESS_TOKEN
}
cdaClient = createClient({
space: config.space,
accessToken: config.cda
})
cpaClient = createClient({
space: config.space,
accessToken: config.cpa,
host: 'preview.contentful.com'
})
}
exports.getCourses = (locale = 'en-US', api = `cda`) => {