UNPKG

@openinc/parse-server-opendash

Version:
33 lines (32 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.init = init; const openinc_geo_graphhopper_common_1 = require("./openinc-geo-graphhopper.common"); async function init(name) { Parse.Cloud.define(name, async function (request) { try { const { startLatitude, startLongitude, endLatitude, endLongitude } = request.params; const response = await (0, openinc_geo_graphhopper_common_1.get)("/route", { locale: "de-DE", vehicle: "car", weighting: "fastest", elevation: "false", use_miles: "false", points_encoded: "false", }, `&point=${startLatitude},${startLongitude}&point=${endLatitude},${endLongitude}`); return response.paths; } catch (error) { console.error(error); return []; } }, { requireUser: true, fields: [ "startLatitude", "startLongitude", "endLatitude", "endLongitude", ], }); }