How to use contentful-management - 9 common examples

To help you get started, we’ve selected a few contentful-management examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github contentful / contentful-management.js / tonic-example.js View on Github external
var contentful = require('contentful-management')
var client = contentful.createClient({
  // This is the access token for this space. Normally you get both ID and the token in the Contentful web app
  accessToken: 'YOUR_ACCESS_TOKEN'
})
// This API call will request a space with the specified ID
var space = await client.getSpace('spaceId')
// Now that we have a space, we can get entries from that space
await space.getEntries()

// let's get a content type
await space.getContentType('product')
.then((contentType) => {
  // and now let's update its name
  contentType.name = 'New Product'
  return contentType.update()
  .then((updatedContentType) => {
    console.log('Update was successful')
github contentful / contentful-cli / test / proxy / client.js View on Github external
const proxyConfig = {
  host: 'localhost',
  port: 8213
}

if (ssl) {
  Object.assign(proxyConfig, {
    protocol: 'https',
    rejectUnauthorized: false
  })
}

const agent = new HttpsProxyAgent(proxyConfig)

const client = createClient({
  accessToken: token,
  httpsAgent: agent
})

client
  .getSpace(space)
  .then(space => {
    space.getEntries().then(console.log)
  })
  .catch(console.error)
github contentful / contentful-space-sync / lib / create-clients.js View on Github external
export default function createClients (opts) {
  return {
    source: {
      delivery: contentful.createClient({
        space: opts.sourceSpace,
        accessToken: opts.sourceSpaceDeliveryToken
      })
    },
    destination: {
      spaceId: opts.destinationSpace,
      management: contentfulManagement.createClient({
        accessToken: opts.destinationSpaceManagementToken
      })
    }
  }
}
github contentful / contentful-migration / src / bin / lib / contentful-client / index.js View on Github external
if (fileConfig.cmaToken) {
      accessTokenConfig.accessToken = fileConfig.cmaToken;
      delete fileConfig.cmaToken;
    }
    if (envToken) {
      accessTokenConfig.accessToken = envToken;
    }
  }

  const config = Object.assign({ httpsAgent }, fileConfig, params, accessTokenConfig);

  if (!config.application) {
    throw new Error('Please specify the application name that uses this client instance');
  }

  return createClient(config);
}
github contentful / ui-extensions-sdk / lib / cli / bin-helpers / command.js View on Github external
function setupCommandContext (options) {
  let urlInfo = url.parse(options.host || 'https://api.contentful.com');
  let host = urlInfo.host;
  let isSecure = urlInfo.protocol === 'https:';

  let client = Contentful.createClient({
    accessToken: options.token,
    host: host,
    secure: isSecure
  });

  return {
    client: client,
    http: http
  };
}
github contentful-labs / file-upload-example / src / app / store / api.js View on Github external
export async function initClient (accessToken, spaceId, host, hostUpload) {
  try {
    client = createClient({
      accessToken,
      host,
      hostUpload
    })

    space = await client.getSpace(spaceId)
  } catch (err) {
    throw err
  }

  return true
}
github deluan / contentful-migrate / lib / store.js View on Github external
const initializeStoreStates = async (accessToken, spaceId, environmentId) => {
  if (typeof cachedState !== 'undefined') {
    return cachedState
  }

  const client = contentful.createClient({ accessToken })
  cachedState = await client.getSpace(spaceId)
    .then(space => space.getEnvironment(environmentId))
    .then(space => space.getEntries(queryParams))
    .then(entries => reduce(entries.items, (acc, entry) => {
      const contentType = entry.fields.contentTypeId[defaultSpaceLocale]
      acc[contentType] = entry.fields.state[defaultSpaceLocale]
      return acc
    }, {}))
  return cachedState
}
github contentful / contentful-import / lib / tasks / init-client.js View on Github external
export default function initClient (opts) {
  const defaultOpts = {
    timeout: 30000,
    logHandler
  }
  const config = {
    ...defaultOpts,
    ...opts
  }
  return createClient(config)
}
github topcoder-platform / community-app / src / server / services / contentful.js View on Github external
export function articleVote(body) {
  const client = contentful.createClient({
    accessToken: config.SECRET.CONTENTFUL.MANAGEMENT_TOKEN,
  });
  return client.getSpace(config.SECRET.CONTENTFUL.EDU.SPACE_ID)
    .then(space => space.getEnvironment('master'))
    .then(environment => environment.getEntry(body.id))
    .then((entry) => {
      if (!entry.fields.upvotes) {
        entry.fields.upvotes = {
          'en-US': body.votes.upvotes,
        };
      } else {
        entry.fields.upvotes['en-US'] = body.votes.upvotes;
      }
      if (!entry.fields.downvotes) {
        entry.fields.downvotes = {
          'en-US': body.votes.downvotes,

contentful-management

Client for Contentful's Content Management API

MIT
Latest version published 1 day ago

Package Health Score

95 / 100
Full package analysis

Popular contentful-management functions

Similar packages