Merge branch 'main' into hit-endpoint
All checks were successful
Run node --check on everything / node-check (push) Successful in 6s
Run node --check on everything / node-check (pull_request) Successful in 9s
Make sure the server is actually able to start / prettier (push) Successful in 24s
Make sure the server is actually able to start / prettier (pull_request) Successful in 27s
Check project using prettier / prettier (pull_request) Successful in 24s
Check project using prettier / prettier (push) Successful in 31s
All checks were successful
Run node --check on everything / node-check (push) Successful in 6s
Run node --check on everything / node-check (pull_request) Successful in 9s
Make sure the server is actually able to start / prettier (push) Successful in 24s
Make sure the server is actually able to start / prettier (pull_request) Successful in 27s
Check project using prettier / prettier (pull_request) Successful in 24s
Check project using prettier / prettier (push) Successful in 31s
This commit is contained in:
commit
146e05751d
1 changed files with 0 additions and 8 deletions
8
index.js
8
index.js
|
@ -4,11 +4,7 @@ import { unlink } from "fs/promises";
|
|||
import { randomUUID } from "crypto";
|
||||
const app = express();
|
||||
const valid_regex = /^[A-Za-z0-9_\-\.]{3,64}$/;
|
||||
function notImplementedHandler(req, res, next) {
|
||||
res.sendStatus(418);
|
||||
}
|
||||
async function get_namespace_id(name, create = true) {
|
||||
console.log(name);
|
||||
return await sql.begin(async (sql) => {
|
||||
if (create) {
|
||||
var potential_res = await sql`
|
||||
|
@ -18,10 +14,8 @@ async function get_namespace_id(name, create = true) {
|
|||
if (!create || potential_res?.length == 0) {
|
||||
var e = await sql`SELECT id FROM namespaces WHERE name = ${name} LIMIT 1`;
|
||||
if (e.length == 0) return null;
|
||||
console.log("e", e, e[0], e[0].id);
|
||||
return e[0].id;
|
||||
} else {
|
||||
console.log("p", potential_res);
|
||||
return potential_res[0].id;
|
||||
}
|
||||
});
|
||||
|
@ -37,7 +31,6 @@ async function add_counter(opts) {
|
|||
} = opts;
|
||||
if (!valid_regex.test(key) || !valid_regex.test(namespace)) return false;
|
||||
const nsid = await get_namespace_id(namespace);
|
||||
console.log(nsid);
|
||||
try {
|
||||
await sql`
|
||||
INSERT INTO keys(
|
||||
|
@ -132,7 +125,6 @@ app.get("/create", async function (req, res) {
|
|||
if (!sane_query?.update_lowerbound) sane_query.update_lowerbound = "-1";
|
||||
if (!sane_query?.update_upperbound) sane_query.update_upperbound = "1";
|
||||
if (!sane_query?.value) sane_query.value = "0";
|
||||
console.log(sane_query);
|
||||
const add_counter_res = await add_counter(sane_query);
|
||||
if (add_counter_res == true) {
|
||||
return res.json({
|
||||
|
|
Loading…
Reference in a new issue