NobGit
public anord read

Ledger

Why work hard when you can work easier?

Languages

Repository composition by tracked source files.

TypeScript
TypeScript 86% CSS 10% SQL 3% Shell 1% HTML 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/anord/ledger.git
ssh://[email protected]:2222/orgs/anord/ledger.git

Trace

apps/api/src/http/routes/attachments.ts

Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.

attachments.ts on main
Author Date Commit Line Code
Alex Nord 3 months ago 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
1
import { mkdir, writeFile } from "node:fs/promises";
Open commit View diff
1 import { mkdir, writeFile } from "node:fs/promises";
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
2
import path from "node:path";
Open commit View diff
2 import path from "node:path";
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
3
import crypto from "node:crypto";
Open commit View diff
3 import crypto from "node:crypto";
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
4
import { Router } from "express";
Open commit View diff
4 import { Router } from "express";
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
5
import { z } from "zod";
Open commit View diff
5 import { z } from "zod";
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
6
import { requireEditor } from "../middleware/auth.js";
Open commit View diff
6 import { requireEditor } from "../middleware/auth.js";
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
7
import { env } from "../../config/env.js";
Open commit View diff
7 import { env } from "../../config/env.js";
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
8
import { pool } from "../../db/pool.js";
Open commit View diff
8 import { pool } from "../../db/pool.js";
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
9
import { getPageMetadata } from "../../services/pages.js";
Open commit View diff
9 import { getPageMetadata } from "../../services/pages.js";
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
10
Open commit View diff
10
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
11
const attachmentSchema = z.object({
Open commit View diff
11 const attachmentSchema = z.object({
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
12
  pageId: z.string().uuid(),
Open commit View diff
12 pageId: z.string().uuid(),
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
13
  fileName: z.string().min(1),
Open commit View diff
13 fileName: z.string().min(1),
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
14
  contentType: z.string().min(3),
Open commit View diff
14 contentType: z.string().min(3),
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
15
  base64Data: z.string().min(1)
Open commit View diff
15 base64Data: z.string().min(1)
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
16
});
Open commit View diff
16 });
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
17
Open commit View diff
17
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
18
export const attachmentsRouter = Router();
Open commit View diff
18 export const attachmentsRouter = Router();
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
19
Open commit View diff
19
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
20
attachmentsRouter.get("/", async (req, res) => {
Open commit View diff
20 attachmentsRouter.get("/", async (req, res) => {
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
21
  const pageId = String(req.query.pageId ?? "");
Open commit View diff
21 const pageId = String(req.query.pageId ?? "");
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
22
  const page = await getPageMetadata(pageId, req.user ?? null);
Open commit View diff
22 const page = await getPageMetadata(pageId, req.user ?? null);
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
23
  if (!page) {
Open commit View diff
23 if (!page) {
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
24
    return res.status(404).json({ error: "Page not found" });
Open commit View diff
24 return res.status(404).json({ error: "Page not found" });
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
25
  }
Open commit View diff
25 }
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
26
Open commit View diff
26
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
27
  const result = await pool.query(
Open commit View diff
27 const result = await pool.query(
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
28
    `SELECT id, page_id, file_name, content_type, storage_path, size_bytes, created_at
Open commit View diff
28 `SELECT id, page_id, file_name, content_type, storage_path, size_bytes, created_at
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
29
     FROM attachments
Open commit View diff
29 FROM attachments
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
30
     WHERE page_id = $1
Open commit View diff
30 WHERE page_id = $1
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
31
     ORDER BY created_at DESC`,
Open commit View diff
31 ORDER BY created_at DESC`,
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
32
    [pageId]
Open commit View diff
32 [pageId]
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
33
  );
Open commit View diff
33 );
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
34
Open commit View diff
34
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
35
  return res.json({ attachments: result.rows });
Open commit View diff
35 return res.json({ attachments: result.rows });
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
36
});
Open commit View diff
36 });
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
37
Open commit View diff
37
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
38
attachmentsRouter.post("/", requireEditor, async (req, res) => {
Open commit View diff
38 attachmentsRouter.post("/", requireEditor, async (req, res) => {
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
39
  const input = attachmentSchema.parse(req.body);
Open commit View diff
39 const input = attachmentSchema.parse(req.body);
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
40
  const page = await getPageMetadata(input.pageId, req.user ?? null);
Open commit View diff
40 const page = await getPageMetadata(input.pageId, req.user ?? null);
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
41
  if (!page) {
Open commit View diff
41 if (!page) {
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
42
    return res.status(404).json({ error: "Page not found" });
Open commit View diff
42 return res.status(404).json({ error: "Page not found" });
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
43
  }
Open commit View diff
43 }
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
44
Open commit View diff
44
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
45
  if (env.STORAGE_PROVIDER !== "local") {
Open commit View diff
45 if (env.STORAGE_PROVIDER !== "local") {
Alex Nord 3 months ago 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
46
    return res.status(400).json({ error: "This Ledger deployment is configured for local storage only." });
Open commit View diff
46 return res.status(400).json({ error: "This Ledger deployment is configured for local storage only." });
Alex Nord 3 months ago 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
47
  }
Open commit View diff
47 }
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
48
Open commit View diff
48
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
49
  const buffer = Buffer.from(input.base64Data, "base64");
Open commit View diff
49 const buffer = Buffer.from(input.base64Data, "base64");
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
50
  const fileId = crypto.randomUUID();
Open commit View diff
50 const fileId = crypto.randomUUID();
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
51
  const ext = path.extname(input.fileName);
Open commit View diff
51 const ext = path.extname(input.fileName);
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
52
  const fileName = `${fileId}${ext}`;
Open commit View diff
52 const fileName = `${fileId}${ext}`;
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
53
Open commit View diff
53
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
54
  await mkdir(env.LOCAL_STORAGE_ROOT, { recursive: true });
Open commit View diff
54 await mkdir(env.LOCAL_STORAGE_ROOT, { recursive: true });
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
55
  const storagePath = path.join(env.LOCAL_STORAGE_ROOT, fileName);
Open commit View diff
55 const storagePath = path.join(env.LOCAL_STORAGE_ROOT, fileName);
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
56
  await writeFile(storagePath, buffer);
Open commit View diff
56 await writeFile(storagePath, buffer);
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
57
Open commit View diff
57
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
58
  const created = await pool.query(
Open commit View diff
58 const created = await pool.query(
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
59
    `
Open commit View diff
59 `
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
60
      INSERT INTO attachments (page_id, file_name, content_type, storage_path, size_bytes, created_by_user_id)
Open commit View diff
60 INSERT INTO attachments (page_id, file_name, content_type, storage_path, size_bytes, created_by_user_id)
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
61
      VALUES ($1, $2, $3, $4, $5, $6)
Open commit View diff
61 VALUES ($1, $2, $3, $4, $5, $6)
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
62
      RETURNING id, file_name, storage_path, size_bytes
Open commit View diff
62 RETURNING id, file_name, storage_path, size_bytes
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
63
    `,
Open commit View diff
63 `,
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
64
    [input.pageId, input.fileName, input.contentType, storagePath, buffer.length, req.user!.id]
Open commit View diff
64 [input.pageId, input.fileName, input.contentType, storagePath, buffer.length, req.user!.id]
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
65
  );
Open commit View diff
65 );
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
66
Open commit View diff
66
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
67
  return res.status(201).json(created.rows[0]);
Open commit View diff
67 return res.status(201).json(created.rows[0]);
same change 4527dbd

First commit v2

Full commit hash
4527dbdfcb1470a5c2476e2a5208f7bf48cc9d27
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
68
});
Open commit View diff
68 });