3 Commits

Author SHA1 Message Date
efarooqui
f093253d87 Removing unecessary console error 2021-06-09 20:01:20 -07:00
efarooqui
011c667805 Unpacking params for request from media 2021-06-09 01:14:02 -07:00
efarooqui
66d7d42497 Adding media fetch endpoint; working query with hardcoded incident 2021-06-08 18:46:33 -07:00
4 changed files with 40 additions and 9475 deletions

Binary file not shown.

9496
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -34,7 +34,7 @@
"object-hash": "^1.3.0",
"ramda": "^0.25.0",
"resource-router-middleware": "^0.6.0",
"xlsx": "^0.17.0"
"xlsx": "^0.16.8"
},
"devDependencies": {
"@babel/cli": "^7.1.2",

View File

@@ -1,5 +1,7 @@
import { version } from '../../package.json'
import fetch from 'node-fetch'
import { Router } from 'express'
import { getParameterByName } from '../lib/util'
import copy from '../copy/en'
export default ({ config, controller }) => {
@@ -22,6 +24,21 @@ export default ({ config, controller }) => {
})
})
api.get('/media/:code', (req, res) => {
const { code } = req.params
fetch(`${process.env.MEDIA_API_ENDPOINT}/${code}`, {
method: 'get',
headers: {
'Authorization': 'Basic ' + new Buffer(process.env.MEDIA_AUTH_USER + ":" + process.env.MEDIA_AUTH_PWORD).toString("base64")
}
})
.then(response => response.json())
.then(data => res.send(data.data))
.catch(err => {
res.status(err.status || 404).send({ error: err.message })
});
})
api.get('/update', (req, res) => {
controller
.update()