initial stuff
Some checks failed
Build and push image for doorman / docker (push) Failing after 35s

This commit is contained in:
Martin Dimitrov 2024-02-25 10:13:25 -08:00
parent d82e150eaa
commit c0ed70e3b6
11 changed files with 52 additions and 8 deletions

View File

@ -5,7 +5,6 @@ ADD bun.lockb bun.lockb
ADD package.json package.json
ADD tsconfig.json tsconfig.json
# install all deps
RUN bun install

BIN
bun.lockb

Binary file not shown.

View File

@ -1,12 +1,12 @@
version: "3"
services:
lnurl_db:
container_name: lnurl-db
image: gitea.chromart.dynv6.net/martin/lnurl-db:latest
doorman:
container_name: doorman
image: gitea.chromart.dedyn.io/martin/doorman:latest
environment:
- CHALLENGE_EXPIRE_MS=105000
- BASE_DOMAIN=chromart.dynv6.net
- BASE_DOMAIN=gitea.chromart.dedyn.io
- REDIS_CONNECT_URL=redis://@redis:6379
depends_on:
- redis

View File

@ -1,5 +1,5 @@
{
"name": "lnurl-db",
"name": "doorman",
"module": "index.ts",
"type": "module",
"workspaces": ["packages/*"],

View File

@ -1,5 +1,5 @@
{
"name": "lnurl-db-client",
"name": "doorman-client",
"version": "0.1.0",
"private": true,
"dependencies": {

View File

@ -1,5 +1,5 @@
{
"name": "lnurl-db-server",
"name": "doorman-server",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",

View File

@ -79,4 +79,8 @@ export class RedisDbClient<A extends RedisModules, B extends RedisFunctions, C e
public async remove(key: string): Promise<string | null> {
return this.client.getDel(key);
}
public getClient() {
return this.client;
}
}

View File

@ -0,0 +1,30 @@
import express from "express";
import { getRedisClient } from "../clients/db/RedisDbProvider";
import { IDoor } from "../types/IDoor";
import { RedisKeys, concatKeys } from "../types/RedisKeys";
const router = express.Router();
const client = await getRedisClient();
router.post('/:id', async(req, res) => {
const door: IDoor = req.body;
await client.getClient().hSet(concatKeys(RedisKeys.DOORS, req.params.id), {
...door
});
res.status(200).json(door);
});
router.get('/:id/status', async(req, res) => {
const isOpen = await client.getClient().exists(concatKeys(RedisKeys.DOORS, req.params.id, 'open'));
if (isOpen) {
res.status(200).json({ status: 'open' });
return;
}
res.status(401).json({ status: 'closed' });
});
export default router;

View File

@ -3,6 +3,7 @@ import fileUpload from "express-fileupload";
import { challengeLimiter, uploadDownloadLimiter } from "./util/RateLimits";
import LnurlRouter from "./routers/LnurlRouter";
import ActionRouter from "./routers/ActionRouter";
import DoorRouter from "./routers/DoorRouter";
const app = express();
@ -21,6 +22,7 @@ app.use(express.static("dist"));
// use routers
app.use('/api/lnurl', LnurlRouter);
app.use('/api/actions', ActionRouter);
app.use('/api/door', DoorRouter);
app.listen(5000, async () => {
console.log("listening on port 5000");

View File

@ -0,0 +1,4 @@
export interface IDoor {
id: string;
open?: string;
}

View File

@ -1,3 +1,8 @@
export enum RedisKeys {
CHALLENGES = "challenges",
DOORS = "doors"
}
export function concatKeys(...keys: String[]) {
return keys.join(':');
}