Closed Murkeee closed 3 months ago
In that case should functions return status codes like this?
if ( keyQuery.length == 0){
await tbl.add([{api_key: key, usage: MAX_USAGE}]);
return res.status(200).send(`Data with values: api_key: ${key}, usage: ${usage}, successfully added to table`)
}
else {
return res.status(406).send("Attempted to add existing key to table");
}
Or should that be handled differently?
In that case should functions return status codes like this?
if ( keyQuery.length == 0){ await tbl.add([{api_key: key, usage: MAX_USAGE}]); return res.status(200).send(`Data with values: api_key: ${key}, usage: ${usage}, successfully added to table`) } else { return res.status(406).send("Attempted to add existing key to table"); }
Or should that be handled differently?
no, i think this should be handled by functions in /actions/*.js
files, they are specifically for req/res related actions.
👍 Got it. Thanks.
Description
This PR fixes #28
Notes for Reviewers Hopefully this is what you want. One function for adding api key to database and another for updating the usage count. Let me know if changes need to be made.
Signed commits