Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
James Triantafylos authored and James Triantafylos committed Mar 7, 2019
1 parent c2b4370 commit 16a8e2d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions chromacache.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ webServerApp.post('/api/clientMessage', async function (req, res) {
collectPalette();
}

async function collectPalette(){
// Calling the fetch image links from color library
async function collectPalette(){
// Calling the fetch image links from color library
let imageLinks = [];
await colorLib.fetchImageLinks(keyword,
'AIzaSyC37-yN0mhRqARSEDJbYC3HaanMUKNNIbw',
Expand All @@ -124,7 +124,7 @@ webServerApp.post('/api/clientMessage', async function (req, res) {
//adds new palette to database
await colorLib.addToDB(dominantPalette);
sendToFrontEnd(dominantPalette);
}
}

// Sends the dominant palette to the client

Expand Down
12 changes: 6 additions & 6 deletions colorlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ module.exports = {

//saving palette to database and giving a success responce
PaletteM.create({date:d, palette: palette})
.catch(function(err){
console.log('unsuccessful: ' + '\n' + err);
});
.catch(function(err){
console.log('unsuccessful: ' + '\n' + err);
});


},
Expand All @@ -197,7 +197,7 @@ module.exports = {
var pal;

//fetching palette from the database
await PaletteM.find({ "palette.keyword": key }, function(err, palette){
await PaletteM.find({ 'palette.keyword': key }, function(err, palette){
if(err){
console.log('error fetching palettes: ' + err);
}else{
Expand All @@ -215,7 +215,7 @@ module.exports = {
},

isStored: async function(key){
var count = await PaletteM.count({ "palette.keyword": key });
var count = await PaletteM.count({ 'palette.keyword': key });
if(count == 0){
return false;
}else{
Expand All @@ -229,7 +229,7 @@ module.exports = {


var valid;
await PaletteM.find({ "palette.keyword": key }, function(err, palette){
await PaletteM.find({ 'palette.keyword': key }, function(err, palette){
if(err){
console.log('error checking validity: ' + err);
}else{
Expand Down
18 changes: 9 additions & 9 deletions models/palette.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
let mongoose = require('mongoose');
let Palette = require('./../colorlib')
let Palette = require('./../colorlib');
let paletteSchema = mongoose.Schema({
palette: {
type: Palette,
require: true
palette: {
type: Palette,
require: true

},
date:{
type: [Number],
require: true
}
},
date:{
type: [Number],
require: true
}

});

Expand Down

0 comments on commit 16a8e2d

Please sign in to comment.