-
Notifications
You must be signed in to change notification settings - Fork 0
/
contentful.js
40 lines (35 loc) · 1.06 KB
/
contentful.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// @ts-nocheck
const contentful = require('contentful')
const contetfulManagement = require("contentful-management");
require("dotenv").config();
const getMigrationOptions = (migrationFunction) => ({
migrationFunction,
spaceId: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_MANAGEMENT_ACCESS_TOKEN,
environmentId: process.env.CONTENTFUL_ENVIRONMENT_ID,
requestBatchSize: process.env.REQUEST_BATCH_SIZE,
});
const client = contentful.createClient({
space: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
environment: process.env.CONTENTFUL_ENVIRONMENT_ID,
});
async function getCMA() {
const cmaClient = contetfulManagement.createClient({
accessToken: process.env.CONTENTFUL_MANAGEMENT_ACCESS_TOKEN,
});
const space = await cmaClient.getSpace(process.env.CONTENTFUL_SPACE_ID);
const environment = await space.getEnvironment(
process.env.CONTENTFUL_ENVIRONMENT_ID
);
return {
cmaClient,
space,
environment,
};
}
module.exports = {
getMigrationOptions,
client,
getCMA,
};