|
|
@ -180,13 +180,23 @@ const ENDPOINTDATA=[ |
|
|
|
function CreateDynamicEndpoints() { |
|
|
|
function CreateDynamicEndpoints() { |
|
|
|
ENDPOINTDATA.map((endpoint)=>{ |
|
|
|
ENDPOINTDATA.map((endpoint)=>{ |
|
|
|
app.get("/ngsplanner/"+endpoint.endpoint,(req,res)=>{ |
|
|
|
app.get("/ngsplanner/"+endpoint.endpoint,(req,res)=>{ |
|
|
|
db2.query('select * from '+endpoint.endpoint+" order by id desc") |
|
|
|
if (endpoint.requiredfields.includes("name")) { |
|
|
|
.then((data)=>{ |
|
|
|
db2.query('select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc') |
|
|
|
res.status(200).json({fields:data.fields,rows:data.rows}) |
|
|
|
.then((data)=>{ |
|
|
|
}) |
|
|
|
res.status(200).json({fields:data.fields,rows:data.rows}) |
|
|
|
.catch((err)=>{ |
|
|
|
}) |
|
|
|
res.status(500).send(err.message) |
|
|
|
.catch((err)=>{ |
|
|
|
}) |
|
|
|
res.status(500).send(err.message) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
db2.query('select * from '+endpoint.endpoint+" order by id desc") |
|
|
|
|
|
|
|
.then((data)=>{ |
|
|
|
|
|
|
|
res.status(200).json({fields:data.fields,rows:data.rows}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch((err)=>{ |
|
|
|
|
|
|
|
res.status(500).send(err.message) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|