Implement /update
All checks were successful
/ prettier (pull_request) Successful in 41s
/ tests (pull_request) Successful in 47s
/ boot (pull_request) Successful in 42s
/ node-check (pull_request) Successful in 10s
/ node-check (push) Successful in 3s
/ prettier (push) Successful in 26s
/ boot (push) Successful in 26s
/ tests (push) Successful in 35s

This commit is contained in:
9pfs 2024-05-25 08:20:55 +00:00
parent 10f8c6fc36
commit cea6569580
Signed by: 9pfs
SSH key fingerprint: SHA256:TOcGxMQCfy4VvRM8AzgXErKXdkAtaTcpGXgYMpyoJoY

View file

@ -117,6 +117,28 @@ app.get("/hit/:key", async function (req, res) {
.status(counter_res == null ? 500 : 200)
.json({ value: counter_res });
});
app.get("/update/:ns/:key", async function (req, res) {
var counter_res = await counter_increment(
req.params.ns,
req.params.key,
req.query.amount,
false,
);
return res
.status(counter_res == null ? 500 : 200)
.json({ value: counter_res });
});
app.get("/update/:key", async function (req, res) {
var counter_res = await counter_increment(
"default",
req.params.key,
req.query.amount,
false,
);
return res
.status(counter_res == null ? 500 : 200)
.json({ value: counter_res });
});
app.get("/get/:ns/:key", async function (req, res) {
var e = await get_counter_value(req.params.ns, req.params.key);
return res.status(e == null ? 404 : 200).json({ value: e });