Skip to content
Snippets Groups Projects
Commit 57f5ed88 authored by Xiao Gui's avatar Xiao Gui
Browse files

netlify fn dataset

parent 8b65c19b
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
const CACHED_DATASET_URL = process.env.CACHED_DATASET_URL
const got = require('got')
exports.handler = (ev, ctx, cb) => {
const {
path,
httpMethod,
headers,
queryStringParameters,
body,
isBase64Encoded,
} = ev
const re = /datasets\/templateNameParcellationName\/\/?(.+)\/(.*?)$/.exec(path)
if (!re) {
return cb(null, { status: 401 })
}
const [ _, templateName, parcellationName ] = re
if (CACHED_DATASET_URL) {
got(CACHED_DATASET_URL)
.then(text => cb(null, {
status: 200,
body: text,
headers: {
'content-type': 'application/json'
}
}))
} else {
return cb(null, {
status: 200,
body: '[]',
headers: {
'content-type': 'application/json'
}
})
}
}
{
"name": "datasets",
"version": "1.0.0",
"description": "",
"main": "datasets.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "apache-2.0",
"dependencies": {
"got": "^11.1.4"
}
}
exports.handler = (ev, ctx, cb) => {
cb(null, {
status: 200,
body: '[]',
headers: {
'Content-type': 'application/json'
}
})
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment