decentralized-internet
Version:
An NPM library of programs to create decentralized web and distributed computing projects
1 lines • 4.47 kB
JavaScript
module.exports=function(e,t){var a=require("./dataprovider.handlers")(e,t),o=require("@hapi/joi"),r=require("clusterpost-model");e.route({path:"/dataprovider",method:"POST",config:{auth:{strategy:"token",scope:["clusterpost","executionserver"]},handler:a.createJob,validate:{query:!1,payload:r.jobpost,params:null},payload:{output:"data"},description:"This route will be used to post job documents to the couch database."}}),e.route({path:"/dataprovider/{id}",method:"DELETE",config:{auth:{strategy:"token",scope:["clusterpost"]},handler:a.deleteJob,validate:{query:!1,params:{id:o.string().alphanum().required()},payload:!1},payload:{output:"data"},description:"This route will be used to delete job documents from the database"}}),e.route({path:"/dataprovider",method:"PUT",config:{auth:{strategy:"token",scope:["clusterpost","executionserver"]},handler:a.updateJob,validate:{query:!1,payload:r.job,params:null},payload:{output:"data"},description:"This route will be used to update a job document in the couch database."}}),e.route({method:"PUT",path:"/dataprovider/{id}/{name}",config:{auth:{strategy:"token",scope:["clusterpost","executionserver"]},handler:a.addData,validate:{query:!1,params:{id:o.string().alphanum().required(),name:o.string().required()},payload:!0},payload:{maxBytes:1073741824,output:"stream"},response:{schema:o.object()},description:"Add attachment data"}}),e.route({method:"GET",path:"/dataprovider/{id}",config:{auth:{strategy:"token",scope:["clusterpost","executionserver"]},handler:a.getJob,validate:{query:!1,params:{id:o.string().alphanum().required()},payload:!1},response:{schema:r.job},description:"Get the job document posted to the database"}}),e.route({method:"GET",path:"/dataprovider",config:{auth:{strategy:"token",scope:["admin"]},handler:a.getAllJobs,validate:{query:o.object().keys({executable:o.string().optional()}).optional(),params:null,payload:!1},response:{schema:o.array().items(r.job).min(0)},description:"Get all document posted to the database"}}),e.route({method:"GET",path:"/dataprovider/count",config:{auth:{strategy:"token",scope:["clusterpost"]},handler:a.getJobCount,validate:{query:!1,params:null,payload:!1},response:{schema:!0},description:"Get all document posted to the database"}}),e.route({method:"GET",path:"/dataprovider/user",config:{auth:{strategy:"token",scope:["clusterpost","executionserver"]},handler:a.getUserJobs,validate:{query:o.object().keys({userEmail:o.string().email().optional(),jobstatus:o.string().optional(),executable:o.string().optional(),executionserver:o.string().optional()}),params:null},response:{schema:o.array().items(r.job).min(0)},description:"Get the jobs posted to the database for a user."}}),e.route({method:"GET",path:"/dataprovider/{id}/{name}",config:{auth:{strategy:"token",scope:["clusterpost","executionserver"]},handler:a.getJob,validate:{query:!1,params:{id:o.string().alphanum().required(),name:o.string().required()},payload:!1},description:"Get a specific attachment of the document posted to the database.",cache:{expiresIn:18e5}}}),e.route({method:"GET",path:"/dataprovider/download/{id}/{name}",config:{auth:{strategy:"token",scope:["clusterpost","executionserver"]},handler:a.getDownloadToken,validate:{query:!1,params:{id:o.string().alphanum().required(),name:o.string().required()},payload:!1},description:'Get a temporary token to download an attachment from a job. This is useful when you want to download a file in a separate window. The query parameter expiresIn is expressed in seconds or a string describing a time span. Eg: 60, "2 days", "10h", "7d"',response:{schema:o.object().keys({token:o.string().required()})}}}),e.route({method:"GET",path:"/dataprovider/download/job/{id}",config:{auth:{strategy:"token",scope:["clusterpost","executionserver"]},handler:a.getDownload,validate:{query:!1,params:{id:o.string().required()},payload:!1},description:"Download job in a tar file"}}),e.route({method:"DELETE",path:"/dataprovider/download/job/{id}",config:{auth:{strategy:"token",scope:["clusterpost","executionserver"]},handler:a.deleteDownload,validate:{query:!1,params:{id:o.string().alphanum().required()},payload:!1},description:"Delete the tar file in temp folder",response:{schema:!0}}}),e.route({method:"GET",path:"/dataprovider/download/{token}",config:{handler:a.downloadAttachment,validate:{query:!1,params:{token:o.string().required()},payload:!1},description:"Get an attachment using a temporary token",cache:{expiresIn:18e5}}})};