diff --git a/README.md b/README.md index 6010aac..fb255d3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # GitHub Metadata Extractor and Updater API -This repository contains an API that can be used to extract metadata from a GitHub repository and update the metadata of a GitHub repository. The API is designed to be used in the context of the [FAIRsoft Evaluator](https://openebench.bsc.es/observatory/Evaluation). The API is used by the [Metadata Extractor for FAIRsoft]() and the [Metadata Updater for FAIRsoft]() applications. The API can be also used using a user access token to perform the same functions. +This repository contains an API that can be used to extract metadata from a GitHub repository and update the metadata of a GitHub repository. The API is designed to be used in the context of the [FAIRsoft Evaluator](https://openebench.bsc.es/observatory/Evaluation). The API is used by the [Metadata Extractor for FAIRsoft](https://github.com/apps/metadata-extractor-for-fairsoft) and the [Metadata Updater for FAIRsoft](https://github.com/apps/metadata-updater-for-fairsoft) applications. The API can be also used using a user access token to perform the same functions. This API is a Node.js application that uses Express.js as the web framework. The API uses the GitHub API to extract and update metadata of a GitHub repository. The API uses the [Octokit](https://github.com/octokit) library to interact with the GitHub API. diff --git a/src/index.js b/src/index.js index 0ce517f..122fb85 100644 --- a/src/index.js +++ b/src/index.js @@ -38,9 +38,19 @@ app.use(helmet()); app.use(require('./metadataExtractor/routes')); app.use(require('./metadataUpdater/routes')); +var options = { + customCss: '.swagger-ui .topbar { display: none }', + customSiteTitle: "GitHub Metadata API", + customfavIcon: "/assets/favicon.ico" + }; + +const path = require('path'); +app.get('/assets/favicon.ico', (req, res) => { + res.sendFile(path.join(__dirname, './assets', 'favicon.ico')); +}); // Serve Swagger docs -app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec)); +app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec, options)); // Starting the server diff --git a/src/metadataUpdater/helpers/metadata.js b/src/metadataUpdater/helpers/metadata.js index cfd5459..66355fb 100644 --- a/src/metadataUpdater/helpers/metadata.js +++ b/src/metadataUpdater/helpers/metadata.js @@ -215,6 +215,14 @@ async function createFile(octokit, owner, repo, branchName, path, content, messa let contents; + // Log the content and its type + console.log('Content:', content); + console.log('Type of content:', typeof content); + + // Optionally, you can check if the content is a valid base64 string + const isBase64 = Buffer.from(content, 'base64').toString('base64') === content; + console.log('Is content a valid base64 string?', isBase64); + try { // Check if the file already exists contents = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', { @@ -241,7 +249,7 @@ async function createFile(octokit, owner, repo, branchName, path, content, messa branch: branchName, message: message, committer: { - name: 'Metadata Updater fir FAIRsoft', + name: 'Metadata Updater for FAIRsoft', email: 'openebench@bsc.es' }, content: content // The new file content, using Base64 encoding. diff --git a/src/metadataUpdater/routes.js b/src/metadataUpdater/routes.js index 77456d7..12e86fb 100644 --- a/src/metadataUpdater/routes.js +++ b/src/metadataUpdater/routes.js @@ -201,7 +201,7 @@ router.post('/metadata/pull', async (req, res) => { try{ - const content = jsonToBase64(metadata); + const content = metadata; console.debug('content created') const octokit = await getOctokit(installationID);