-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from kylorobs/master
cloudinary and firebase endpoints
- Loading branch information
Showing
7 changed files
with
987 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.