Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
refactor: rm unused resources from hub backend
Browse files Browse the repository at this point in the history
  • Loading branch information
imsergiy committed Sep 1, 2020
1 parent 828fb1f commit 81dbbea
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
17 changes: 0 additions & 17 deletions hub-resources/db.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const MongoClient = require('mongodb').MongoClient;
const ObjectId = require('mongodb').ObjectID;

let db;

Expand Down Expand Up @@ -27,22 +26,6 @@ async function findAndModify(collection, param, data) {
return db.collection(collection).findOneAndUpdate(param, data, { upsert: true, returnNewDocument: true });
}

async function insertMany(collection, data) {
return db.collection(collection).insertMany(data);
}

async function update(collection, params, data) {
return db.collection(collection).findOneAndUpdate(params, data, { returnOriginal: false });
}

async function remove(collection, params) {
return db.collection(collection).deleteOne(params);
}

async function removeMany(collection, params) {
return db.collection(collection).deleteMany(params);
}

module.exports = {
async initMongo(MONGO_URL) {
const mongo = await MongoClient.connect(MONGO_URL, { useUnifiedTopology: true });
Expand Down
19 changes: 0 additions & 19 deletions hub-resources/hubAPI.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const express = require('express')
const fs = require('fs');
const axios = require('axios');
const cors = require('cors');
const db = require('./db');
Expand Down Expand Up @@ -323,22 +322,4 @@ async function getImageDetails(image, id) {
imageData.readmeHTML = readmeRendered;

return imageData;
}

function promisify(inner) {
return new Promise((resolve, reject) =>
inner((err, res) => {
if (err) { reject(err) }

resolve(res);
})
);
}

function readFile(filename) {
return promisify(cb => fs.readFile(filename, cb));
}

function writeFile(filename, data) {
return promisify(cb => fs.writeFile(filename, data, cb));
}

0 comments on commit 81dbbea

Please sign in to comment.