Skip to content

Commit

Permalink
Merge pull request #2 from kylorobs/master
Browse files Browse the repository at this point in the history
cloudinary and firebase endpoints
  • Loading branch information
dev-kylo authored Mar 10, 2020
2 parents 5396b58 + aa339e8 commit 0081a90
Show file tree
Hide file tree
Showing 7 changed files with 987 additions and 5 deletions.
34 changes: 34 additions & 0 deletions cloudinaryInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var cloudinary = require('cloudinary').v2;
var presets = require('./cloudinaryPresets.js')

cloudinary.config({
cloud_name: 'kclsu-media',
api_key: '148547584157183',
api_secret: '2LDCxvbrh_TCIS6xxPWhCBrVb4Q'
});

function cloudinaryUpload(data){
return cloudinary.uploader.upload(data.imageRef, { folder: "website_uploads/", public_id: 'kings6'}, (error, result) => {
if (error) console.log('Error: ', error)
return result
});
}

function manipulateImage(public_id, data){
let preset = !data.preset? {} : presets[data.preset];
if (data.edit) preset = editPreset(preset);
let promise = new Promise(resolve => {
let transform = cloudinary.url(public_id, { transformation: preset});
resolve(transform)
})
return promise;
}

function editPreset(preset){
console.log('Editing Preset...')
}

module.exports = {
cloudinaryUpload: cloudinaryUpload,
manipulateImage: manipulateImage
};
20 changes: 20 additions & 0 deletions cloudinaryPresets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

const Home_Banner = {
width: 780,
height: 600,
crop: 'fill',
quality: 'auto:best',
gravity: 'faces:auto'
}

const Page_Banner = {
width: 1200,
height: 678,
crop: 'fill',
quality: 'auto:best',
gravity: 'faces:auto'
}

module.exports = {
Home_Banner, Page_Banner
}
2 changes: 1 addition & 1 deletion fetchNews.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var fetch = require('node-fetch')
var fetch = require('node-fetch');

function fetchNews(url){
return fetch(url)
Expand Down
28 changes: 28 additions & 0 deletions firebaseAuth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var fetch = require('node-fetch')
var token;
require('dotenv').config();

function firebaseAuth(str){

token = process.env.FIREBASE_VARSITY_KEY;

let url = 'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=' + token;

let postData = {};
postData.method = 'POST';
postData.body = JSON.stringify(str);
postData.headers = {
'Content-Type': 'application/json'
}


return fetch(url, postData)
.then(response => {
return response.json();
})
.catch(err => {
return {status: "Failed", error: err}
})
}

module.exports = firebaseAuth;
Loading

0 comments on commit 0081a90

Please sign in to comment.