This commit is contained in:
@ -14,8 +14,9 @@ module.exports = (fastify, opts, done) => {
|
||||
}
|
||||
}).then(res=>reply.send(res.data));
|
||||
}else{
|
||||
reply.send([]);
|
||||
return reply.send([]);
|
||||
}
|
||||
return reply
|
||||
});
|
||||
fastify.get('/place/:id', async (req,reply) => {
|
||||
const ENDPOINT = 'https://nominatim.openstreetmap.org/';
|
||||
@ -28,31 +29,32 @@ module.exports = (fastify, opts, done) => {
|
||||
}
|
||||
}).then(res=>reply.send(res.data));
|
||||
}else{
|
||||
reply.send([]);
|
||||
return reply.send([]);
|
||||
}
|
||||
return reply;
|
||||
});
|
||||
|
||||
fastify.get('/:id', async (req, reply) => {
|
||||
if(req.params.id == undefined){
|
||||
if(req.params.id == undefined)
|
||||
return reply.code(400).send({error:"No ID query parameter"});
|
||||
}
|
||||
|
||||
return fastify.level.db.get(req.params.id, (err, val) => {
|
||||
fastify.level.db.get(req.params.id, (err, val) => {
|
||||
if(err){
|
||||
console.warn(err);
|
||||
reply.send({name:"New Journey", main:[]});
|
||||
} else {
|
||||
console.log(JSON.parse(val))
|
||||
reply.send(JSON.parse(val));
|
||||
}
|
||||
});
|
||||
return reply
|
||||
});
|
||||
|
||||
fastify.post('/:id', async (req, reply) => {
|
||||
if(req.params.id == undefined){
|
||||
if(req.params.id == undefined)
|
||||
return reply.code(400).send({error:"No ID query parameter"});
|
||||
}
|
||||
|
||||
return fastify.level.db.put(req.params.id, JSON.stringify(req.body), (err) => {
|
||||
fastify.level.db.put(req.params.id, JSON.stringify(req.body), (err) => {
|
||||
if(err){
|
||||
console.warn(err);
|
||||
reply.code(500).send({error:"Error with DB"});
|
||||
@ -60,25 +62,8 @@ module.exports = (fastify, opts, done) => {
|
||||
reply.send({content:"ok"});
|
||||
}
|
||||
});
|
||||
return reply
|
||||
});
|
||||
|
||||
// fastify.delete('/:id',(req, reply) => {
|
||||
// if(req.params.id == undefined){
|
||||
// reply.code(400).send({error:"No ID query parameter"});
|
||||
// } else {
|
||||
// fastify.level.delete(req.params.id,(err) => {
|
||||
// if(err){
|
||||
// console.warn(err);
|
||||
// reply.code(500).send({error:"Error with DB"});
|
||||
// } else {
|
||||
// reply.send({content:"ok"});
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
done();
|
||||
};
|
Reference in New Issue
Block a user