Skip to content

Commit

Permalink
begin writing routes/handlers for posting a sequence
Browse files Browse the repository at this point in the history
ref #10
  • Loading branch information
maxgrossman committed May 21, 2018
1 parent 038416b commit a80cb55
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 4 deletions.
9 changes: 5 additions & 4 deletions adapters/sequence/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ Promise = require('bluebird')
/**
*
* @param {array} paths list of directory paths holding images to make sequences of
* @param {number} cutDist maximum distance allowed between two photos
* @param {number} maxCutDist maximum distance allowed between two photos
* @param {number} minCutDist minimum distance allowed between two photos
* @param {cutTime} cutTime maximum time between two images
* @param {cutSize} cutSize maximum size of a sequence.
* @return {array} array of sequence configuration objects
*/

module.exports = (paths, cutDist, cutTime, cutSize) => {
module.exports = (paths, minCutDist, maxCutDist, cutTime, cutSize) => {
return new Promise((resolve, reject) => {
Promise.map(paths, async (p) => {
const images = await fs.readdir(p);
Expand All @@ -25,8 +26,8 @@ module.exports = (paths, cutDist, cutTime, cutSize) => {
.then(async (images) => {
try {
const params = {
maxDist: cutDist || 300,
minDist: 1,
maxDist: maxCutDist || 300,
minDist: minCutDist || 0.5,
maxDetla: cutTime || 120,
size: cutSize || 0
},
Expand Down
4 changes: 4 additions & 0 deletions connection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';

const connection = require('./knexfile')[process.env.NODE_ENV || 'development']
module.exports = require('knex')(connection);
Empty file added handlers/index.js
Empty file.
Binary file added handlers/sequence/.post.js.swp
Binary file not shown.
15 changes: 15 additions & 0 deletions handlers/sequence/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

exports.insertImages = (sequenceId, userId sequences) => {
const sequence = sequences[sequenceId];

Promise.map(sequence, image => {
return Object
.values(image)
.concat([sequenceId, userId])
.join(',');
})
.then((values) => `the insert`)
.catch((error) => { throw error });

}
Empty file added handlers/sequence/index.js
Empty file.
12 changes: 12 additions & 0 deletions handlers/sequence/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

const Boom = require('boom');
const db = require('../../connection');
const uuidv4 = require('uuid/v4');

module.exports = async (r, h) => {
try {
} catch (error) {
return Boom.badImplementation(error.message);
}
}
5 changes: 5 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = [
require('./sequence').post
]
5 changes: 5 additions & 0 deletions routes/sequence/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
post: require('./post')
}
15 changes: 15 additions & 0 deletions routes/sequence/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

const sequencesSchema = require('../../schema/sequences.js');

module.exports = {
method: 'POST',
path: '/sequence',
config: {
handler: require('../../handlers/sequence').get,
validate: {
payload: sequencesSchema,
failAction: async (r, h, err) => err
}
}
}

0 comments on commit a80cb55

Please sign in to comment.