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 package.json package.json
ADD tsconfig.json tsconfig.json ADD tsconfig.json tsconfig.json
# install all deps # install all deps
RUN bun install RUN bun install

BIN
bun.lockb

Binary file not shown.

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
{ {
"name": "lnurl-db-server", "name": "doorman-server",
"version": "1.0.0", "version": "1.0.0",
"main": "index.js", "main": "index.js",
"license": "MIT", "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> { public async remove(key: string): Promise<string | null> {
return this.client.getDel(key); 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 { challengeLimiter, uploadDownloadLimiter } from "./util/RateLimits";
import LnurlRouter from "./routers/LnurlRouter"; import LnurlRouter from "./routers/LnurlRouter";
import ActionRouter from "./routers/ActionRouter"; import ActionRouter from "./routers/ActionRouter";
import DoorRouter from "./routers/DoorRouter";
const app = express(); const app = express();
@ -21,6 +22,7 @@ app.use(express.static("dist"));
// use routers // use routers
app.use('/api/lnurl', LnurlRouter); app.use('/api/lnurl', LnurlRouter);
app.use('/api/actions', ActionRouter); app.use('/api/actions', ActionRouter);
app.use('/api/door', DoorRouter);
app.listen(5000, async () => { app.listen(5000, async () => {
console.log("listening on port 5000"); 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 { export enum RedisKeys {
CHALLENGES = "challenges", CHALLENGES = "challenges",
DOORS = "doors"
}
export function concatKeys(...keys: String[]) {
return keys.join(':');
} }