Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudinary and Firebase endpoints #2

Merged
merged 2 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;