Update index.js
This commit is contained in:
parent
008eec6e1d
commit
e223e1ae75
1 changed files with 23 additions and 1 deletions
24
index.js
24
index.js
|
@ -103,7 +103,29 @@ async function searchElement(request, response) {
|
||||||
|
|
||||||
// Set a db variable
|
// Set a db variable
|
||||||
|
|
||||||
app.put('/api/:auth/database/:element/set/:data', set);
|
app.put('/api/:auth/database/:element/set/:data', (request, response) => {
|
||||||
|
var token = request.params.auth;
|
||||||
|
var element = request.params.element;
|
||||||
|
var data = request.params.data;
|
||||||
|
|
||||||
|
set = 'set '+element+' to '+data
|
||||||
|
authenticate(token, response, set)
|
||||||
|
|
||||||
|
await db.set(element, data)
|
||||||
|
var res = await db.get(element)
|
||||||
|
// var res = JSON.parse(res);
|
||||||
|
if(res) {
|
||||||
|
var reply = {
|
||||||
|
status: 'Done'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
var reply = {
|
||||||
|
status:"404 - Not Found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response.send(reply);
|
||||||
|
});
|
||||||
|
|
||||||
async function set(request, response) {
|
async function set(request, response) {
|
||||||
var token = request.params.auth;
|
var token = request.params.auth;
|
||||||
|
|
Loading…
Reference in a new issue