Skip to content

Commit

Permalink
docs: customize docs
Browse files Browse the repository at this point in the history
  • Loading branch information
EvaMart committed Sep 10, 2024
1 parent cfcd432 commit 15b2e3a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
12 changes: 11 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/metadataUpdater/helpers/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}', {
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/metadataUpdater/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 15b2e3a

Please sign in to comment.