diff --git a/lib/www/server/lib/db/project/configuration/get.js b/lib/www/server/lib/db/project/configuration/get.js new file mode 100644 index 0000000..4da447d --- /dev/null +++ b/lib/www/server/lib/db/project/configuration/get.js @@ -0,0 +1,25 @@ +const { setSurvey } = require('../../connection'); + +async function get (projectId, opts = {}) { + try { + const client = await setSurvey(); // Use public schema + + const text = ` + SELECT meta + FROM projects + WHERE pid = $1; + `; + + const res = await client.query(text, [projectId]); + client.release(); + return res.rows[0]; + } catch (err) { + if (err.code == "42P01") { + throw { status: 404, message: "Not found" }; + } else { + throw err; + } + } +} + +module.exports = get; diff --git a/lib/www/server/lib/db/project/configuration/index.js b/lib/www/server/lib/db/project/configuration/index.js new file mode 100644 index 0000000..b2285fc --- /dev/null +++ b/lib/www/server/lib/db/project/configuration/index.js @@ -0,0 +1,8 @@ + +module.exports = { + get: require('./get'), + // post: require('./post'), + // put: require('./put'), + // patch: require('./patch'), + // delete: require('./delete'), +}; diff --git a/lib/www/server/lib/db/project/index.js b/lib/www/server/lib/db/project/index.js index 42301eb..39fd933 100644 --- a/lib/www/server/lib/db/project/index.js +++ b/lib/www/server/lib/db/project/index.js @@ -5,4 +5,5 @@ module.exports = { put: require('./put'), delete: require('./delete'), summary: require('./summary'), + configuration: require('./configuration'), }