Run prettier
All checks were successful
/ prettier (pull_request) Successful in 16s
/ boot (pull_request) Successful in 14s
/ node-check (pull_request) Successful in 3s
/ tests (pull_request) Successful in 20s
/ node-check (push) Successful in 3s
/ prettier (push) Successful in 28s
/ boot (push) Successful in 26s
/ tests (push) Successful in 44s
All checks were successful
/ prettier (pull_request) Successful in 16s
/ boot (pull_request) Successful in 14s
/ node-check (pull_request) Successful in 3s
/ tests (pull_request) Successful in 20s
/ node-check (push) Successful in 3s
/ prettier (push) Successful in 28s
/ boot (push) Successful in 26s
/ tests (push) Successful in 44s
This commit is contained in:
parent
9e5dac8dfb
commit
57a6494261
1 changed files with 14 additions and 15 deletions
29
index.js
29
index.js
|
@ -5,14 +5,14 @@ import { randomUUID } from "crypto";
|
|||
const app = express();
|
||||
const valid_regex = /^[A-Za-z0-9_\-\.]{3,64}$/;
|
||||
var stats = {
|
||||
keys_created: 0,
|
||||
keys_updated: 0,
|
||||
requests: 0,
|
||||
version: "who knows?"
|
||||
keys_created: 0,
|
||||
keys_updated: 0,
|
||||
requests: 0,
|
||||
version: "who knows?",
|
||||
};
|
||||
app.use((req, res, next) => {
|
||||
stats.requests++;
|
||||
return next();
|
||||
stats.requests++;
|
||||
return next();
|
||||
});
|
||||
|
||||
async function get_namespace_id(name, create = true) {
|
||||
|
@ -117,10 +117,9 @@ async function counter_increment(ns_name, key, offset, create = false) {
|
|||
${offset < 0 ? sql`update_lowerbound <= ${offset}` : sql`update_upperbound >= ${offset}`}
|
||||
RETURNING value`;
|
||||
if (sql_res.length == 1) {
|
||||
stats.keys_updated++;
|
||||
return parseInt(sql_res[0].value);
|
||||
}
|
||||
else return null;
|
||||
stats.keys_updated++;
|
||||
return parseInt(sql_res[0].value);
|
||||
} else return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -132,9 +131,9 @@ async function counter_update(ns_name, key, amount) {
|
|||
await sql`SELECT value FROM keys WHERE name = ${key} AND namespace_id = ${nsid}`;
|
||||
if (res.length == 0) return null;
|
||||
else {
|
||||
stats.keys_updated++;
|
||||
return parseInt(res[0].value);
|
||||
}
|
||||
stats.keys_updated++;
|
||||
return parseInt(res[0].value);
|
||||
}
|
||||
}
|
||||
|
||||
async function counter_set(ns_name, key, value) {
|
||||
|
@ -305,8 +304,8 @@ app.get("/create", async function (req, res) {
|
|||
}
|
||||
});
|
||||
|
||||
app.get("/stats", function(req, res) {
|
||||
return res.json(stats);
|
||||
app.get("/stats", function (req, res) {
|
||||
return res.json(stats);
|
||||
});
|
||||
|
||||
const listen_path =
|
||||
|
|
Loading…
Reference in a new issue