Compare commits

...

2 commits

Author SHA1 Message Date
31301a068b
Use literal regex
All checks were successful
Run node --check on everything / node-check (push) Successful in 7s
Check project using prettier / prettier (push) Successful in 32s
2024-05-24 17:47:50 +00:00
085bfc78c9
Run prettier
All checks were successful
Run node --check on everything / node-check (push) Successful in 2s
Check project using prettier / prettier (push) Successful in 13s
2024-05-24 17:30:46 +00:00

View file

@ -3,7 +3,7 @@ import express from "express";
import { unlink } from "fs/promises";
import { randomUUID } from "crypto";
const app = express();
const valid_regex = new RegExp("^[A-Za-z0-9_\-.]{3,64}$");
const valid_regex = /^[A-Za-z0-9_\-\.]{3,64}$/;
function notImplementedHandler(req, res, next) {
res.sendStatus(418);
}
@ -24,8 +24,14 @@ async function get_namespace_id(name) {
});
}
async function add_counter(opts) {
const { key, value, enable_reset, update_lowerbound, update_upperbound, namespace } =
opts;
const {
key,
value,
enable_reset,
update_lowerbound,
update_upperbound,
namespace,
} = opts;
if (!valid_regex.test(key) || !valid_regex.test(namespace)) return false;
const nsid = await get_namespace_id(namespace);
console.log(nsid);