add table
This commit is contained in:
parent
403ce696bc
commit
e9956486fd
2
plugin
2
plugin
@ -1 +1 @@
|
||||
Subproject commit 73733c0292cb3f0d6775c69c734e80c690932777
|
||||
Subproject commit 834850afae81abce873da8be8792614ab8cc0b76
|
11
server/package-lock.json
generated
11
server/package-lock.json
generated
@ -12,6 +12,7 @@
|
||||
"@prisma/client": "^4.0.0",
|
||||
"bloom-filters": "^3.0.0",
|
||||
"body-parser": "^1.20.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.13.2",
|
||||
"crc": "^4.1.1",
|
||||
"dotenv": "^16.0.1",
|
||||
@ -938,6 +939,11 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/class-transformer": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz",
|
||||
"integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw=="
|
||||
},
|
||||
"node_modules/class-validator": {
|
||||
"version": "0.13.2",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.13.2.tgz",
|
||||
@ -5977,6 +5983,11 @@
|
||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
|
||||
"integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ=="
|
||||
},
|
||||
"class-transformer": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz",
|
||||
"integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw=="
|
||||
},
|
||||
"class-validator": {
|
||||
"version": "0.13.2",
|
||||
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.13.2.tgz",
|
||||
|
@ -19,6 +19,7 @@
|
||||
"@prisma/client": "^4.0.0",
|
||||
"bloom-filters": "^3.0.0",
|
||||
"body-parser": "^1.20.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.13.2",
|
||||
"crc": "^4.1.1",
|
||||
"dotenv": "^16.0.1",
|
||||
|
@ -0,0 +1,10 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "EncryptedEmbed" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"note_id" TEXT NOT NULL,
|
||||
"embed_id" TEXT NOT NULL,
|
||||
"ciphertext" BLOB NOT NULL,
|
||||
"hmac" TEXT NOT NULL,
|
||||
"size_bytes" INTEGER NOT NULL,
|
||||
CONSTRAINT "EncryptedEmbed_note_id_fkey" FOREIGN KEY ("note_id") REFERENCES "EncryptedNote" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
@ -11,12 +11,23 @@ datasource db {
|
||||
}
|
||||
|
||||
model EncryptedNote {
|
||||
id String @id @default(cuid())
|
||||
insert_time DateTime @default(now())
|
||||
expire_time DateTime @default(now())
|
||||
id String @id @default(cuid())
|
||||
insert_time DateTime @default(now())
|
||||
expire_time DateTime @default(now())
|
||||
ciphertext String
|
||||
hmac String
|
||||
crypto_version String @default("v1")
|
||||
crypto_version String @default("v1")
|
||||
EncryptedEmbed EncryptedEmbed[]
|
||||
}
|
||||
|
||||
model EncryptedEmbed {
|
||||
id String @id @default(cuid())
|
||||
note_id String
|
||||
embed_id String
|
||||
ciphertext Bytes
|
||||
hmac String
|
||||
size_bytes Int
|
||||
note EncryptedNote @relation(fields: [note_id], references: [id])
|
||||
}
|
||||
|
||||
model event {
|
||||
|
@ -10,7 +10,7 @@ import { deleteExpiredNotes, deleteInterval } from "./tasks/deleteExpiredNotes";
|
||||
export const app: Express = express();
|
||||
|
||||
// Enable JSON body parsing
|
||||
app.use(express.json({}));
|
||||
app.use(express.json({ limit: "8MB" }));
|
||||
|
||||
// configure logging
|
||||
app.use(
|
||||
|
@ -12,7 +12,24 @@ import {
|
||||
ValidateIf,
|
||||
ValidationError,
|
||||
Matches,
|
||||
ValidateNested,
|
||||
IsString,
|
||||
} from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
|
||||
export class EncryptedEmbed {
|
||||
@IsBase64()
|
||||
@IsNotEmpty()
|
||||
ciphertext: string | undefined;
|
||||
|
||||
@IsBase64()
|
||||
@IsNotEmpty()
|
||||
hmac: string | undefined;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
embedId: string | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request body for creating a note
|
||||
@ -36,6 +53,10 @@ export class NotePostRequest {
|
||||
|
||||
@Matches("^v[0-9]+$")
|
||||
crypto_version: string = "v1";
|
||||
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => EncryptedEmbed)
|
||||
embeds: EncryptedEmbed[] = [];
|
||||
}
|
||||
|
||||
export async function postNoteController(
|
||||
|
@ -5,7 +5,7 @@ import { postNoteController } from "./note.post.controller";
|
||||
|
||||
export const notesRoute = express.Router();
|
||||
|
||||
const jsonParser = express.json({ limit: "500k" });
|
||||
const jsonParser = express.json({ limit: "8MB" });
|
||||
|
||||
const postRateLimit = rateLimit({
|
||||
windowMs: parseFloat(process.env.POST_LIMIT_WINDOW_SECONDS as string) * 1000,
|
||||
|
Loading…
Reference in New Issue
Block a user