Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions upload-api/src/services/contentful/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ const createContentfulMapper = async (
const cleanLocalPath = localPath?.replace?.(/\/$/, '');
const fetchedLocales: [] = await extractLocale(cleanLocalPath);

const mapperConfig = {
method: 'post',
maxBodyLength: Infinity,
url: `${process.env.NODE_BACKEND_API}/v2/migration/localeMapper/${projectId}`,
headers: {
app_token,
'Content-Type': 'application/json'
},
data: {
locale: Array.from(fetchedLocales)
}
};

const mapRes = await axios.request(mapperConfig);
if (mapRes?.status == 200) {
logger.info('Legacy CMS', {
status: HTTP_CODES?.OK,
message: HTTP_TEXTS?.LOCALE_SAVED
});
}

await extractContentTypes(cleanLocalPath, affix);
const initialMapper = await createInitialMapper(cleanLocalPath, affix);
// Must run after createInitialMapper: that step deletes contentfulMigrationData (contentfulSchema) and would remove taxonomy files written earlier.
Expand Down Expand Up @@ -67,26 +88,6 @@ const createContentfulMapper = async (
});
}

const mapperConfig = {
method: 'post',
maxBodyLength: Infinity,
url: `${process.env.NODE_BACKEND_API}/v2/migration/localeMapper/${projectId}`,
headers: {
app_token,
'Content-Type': 'application/json'
},
data: {
locale: Array.from(fetchedLocales)
}
};

const mapRes = await axios.request(mapperConfig);
if (mapRes?.status == 200) {
logger.info('Legacy CMS', {
status: HTTP_CODES?.OK,
message: HTTP_TEXTS?.LOCALE_SAVED
});
}
} catch (err: any) {
console.error('🚀 ~ createContentfulMapper ~ err:', err?.response?.data ?? err);
logger.warn('Validation error:', {
Expand Down
Loading