Move stats to utils.js
All checks were successful
/ node-check (pull_request) Successful in 3s
/ prettier (pull_request) Successful in 27s
/ boot (pull_request) Successful in 26s
/ tests (pull_request) Successful in 37s
/ tests (push) Successful in 20s
/ prettier (push) Successful in 5s
/ node-check (push) Successful in 3s
/ boot (push) Successful in 3s

This commit is contained in:
9pfs 2024-06-14 01:52:56 +00:00
parent 6edff2c74e
commit 06f52fc2b4
Signed by: 9pfs
SSH key fingerprint: SHA256:TOcGxMQCfy4VvRM8AzgXErKXdkAtaTcpGXgYMpyoJoY
2 changed files with 7 additions and 6 deletions

View file

@ -9,12 +9,6 @@ import {
counter_set,
} from "./utils.js";
const app = express();
var stats = {
keys_created: 0,
keys_updated: 0,
requests: 0,
version: "who knows?",
};
app.use((req, res, next) => {
stats.requests++;
return next();

View file

@ -1,6 +1,13 @@
import sql from "./db.js";
const valid_regex = /^[A-Za-z0-9_\-\.]{3,64}$/;
var namespace_id_cache = {};
/* TODO: put stats into its own file */
export var stats = {
keys_created: 0,
keys_updated: 0,
requests: 0,
version: "who knows?",
};
export async function get_namespace_id(name, create = true) {
return await sql.begin(async (sql) => {