diff --git a/adapters/sequence/index.js b/adapters/sequence/index.js index 960cd79..d4ef8de 100644 --- a/adapters/sequence/index.js +++ b/adapters/sequence/index.js @@ -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); @@ -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 }, diff --git a/connection.js b/connection.js new file mode 100644 index 0000000..62e1dbb --- /dev/null +++ b/connection.js @@ -0,0 +1,4 @@ +'use strict'; + +const connection = require('./knexfile')[process.env.NODE_ENV || 'development'] +module.exports = require('knex')(connection); diff --git a/handlers/index.js b/handlers/index.js new file mode 100644 index 0000000..e69de29 diff --git a/handlers/sequence/.post.js.swp b/handlers/sequence/.post.js.swp new file mode 100644 index 0000000..1ae60cc Binary files /dev/null and b/handlers/sequence/.post.js.swp differ diff --git a/handlers/sequence/helpers.js b/handlers/sequence/helpers.js new file mode 100644 index 0000000..050c061 --- /dev/null +++ b/handlers/sequence/helpers.js @@ -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 }); + +} diff --git a/handlers/sequence/index.js b/handlers/sequence/index.js new file mode 100644 index 0000000..e69de29 diff --git a/handlers/sequence/post.js b/handlers/sequence/post.js new file mode 100644 index 0000000..c743da3 --- /dev/null +++ b/handlers/sequence/post.js @@ -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); + } +} diff --git a/routes/index.js b/routes/index.js new file mode 100644 index 0000000..a63fc2e --- /dev/null +++ b/routes/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = [ + require('./sequence').post +] diff --git a/routes/sequence/index.js b/routes/sequence/index.js new file mode 100644 index 0000000..c770af0 --- /dev/null +++ b/routes/sequence/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + post: require('./post') +} diff --git a/routes/sequence/post.js b/routes/sequence/post.js new file mode 100644 index 0000000..e8f6f7f --- /dev/null +++ b/routes/sequence/post.js @@ -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 + } + } +}