Some checks failed
/ build (map[dockerfile:./services/tasks/Dockerfile name:tasks]) (push) Failing after 1m25s
/ deploy (push) Has been skipped
/ build (map[dockerfile:./services/files/Dockerfile name:files]) (push) Failing after 1m34s
/ build (map[dockerfile:./services/app/Dockerfile name:app]) (push) Successful in 2m9s
/ build (map[dockerfile:./services/api/Dockerfile name:api]) (push) Failing after 1m42s
/ build (map[dockerfile:./services/web/Dockerfile name:web]) (push) Failing after 1m18s
/ build (map[dockerfile:./services/watchers/Dockerfile name:watchers]) (push) Failing after 1m22s
/ build (map[dockerfile:./services/hasura/Dockerfile name:hasura]) (push) Successful in 2m3s
32 lines
731 B
JavaScript
32 lines
731 B
JavaScript
const { ConvertTo3waClient } = require("@what3words/api")
|
|
const { ctx } = require("@modjo/core")
|
|
|
|
// see https://developer.what3words.com/public-api
|
|
|
|
const what3wordsConfig = {
|
|
host: "https://api.what3words.com",
|
|
apiVersion: "v3",
|
|
}
|
|
|
|
module.exports = async function what3words(coords, options = {}) {
|
|
const config = ctx.get("config.project")
|
|
const { what3wordsApiKey } = config
|
|
|
|
const w3wClient = ConvertTo3waClient.init(what3wordsApiKey, what3wordsConfig)
|
|
|
|
const [lng, lat] = coords
|
|
|
|
let data
|
|
try {
|
|
data = await w3wClient.run({
|
|
coordinates: { lat, lng },
|
|
language: "fr",
|
|
format: "json",
|
|
...options,
|
|
})
|
|
// data = res.data
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
return data
|
|
}
|