postLocation.js 588 Bytes
const createError = require('http-errors')
const su = require('superagent')
const { path, head } = require('ramda');

const dbhost = process.env.COUCHDB_URL
const dbubicaciones = process.env.DB_UBICACIONES

const headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
}

const postLocation = (payload) =>
  su.post(`${dbhost}/${dbubicaciones}/`)
  .set(headers)
  .send(JSON.stringify(payload))

module.exports = (req, res, next) => {
  postLocation(req.body)
  .then(() => res.json({ success: true, error: false }))
  .catch(error => next(createError(500)))
}