crowdstart.js
Version:
Ecommerce SDK for JavaScript and client for Crowdstart.
38 lines (33 loc) • 819 B
text/coffeescript
{statusCreated, statusNoContent, statusOk} = require '../utils'
endpoint = (x) ->
"#{x.siteId}/deploy"
byId = (x) ->
"#{endpoint x}/#{x.id ? x.deployId}"
upload = (x) ->
"#{byId x}/#{x.path}"
module.exports = (blueprints) ->
blueprints.deploy =
create:
url: endpoint
method: 'POST'
expects: statusCreated
update:
url: byId
method: 'PATCH'
expects: statusOk
delete:
url: byId
method: 'DELETE'
expects: statusNoContent
restore:
url: byId
method: 'POST'
expects: statusOk
upload:
url: upload
method: 'PUT'
expects: statusOk
headers:
'Content-Type': 'application/octet-stream'
streams: (x) -> fs.createReadStream x.absolutePath
followRedirects: true