mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-25 15:06:26 -08:00
misc updates
This commit is contained in:
parent
04a34665f9
commit
8845e9c775
|
@ -1,5 +1,6 @@
|
||||||
import {z} from "zod"
|
import {z} from "zod"
|
||||||
import { FileId, FileVisibility } from "./files.js"
|
import { FileId, FileVisibility } from "./files.js"
|
||||||
|
import { RGBHex } from "./misc.js"
|
||||||
|
|
||||||
export const StringPassword = z.string().min(8,"password must be at least 8 characters")
|
export const StringPassword = z.string().min(8,"password must be at least 8 characters")
|
||||||
export const Password =
|
export const Password =
|
||||||
|
@ -46,7 +47,7 @@ export namespace Settings {
|
||||||
barSide: BarSide.default("left")
|
barSide: BarSide.default("left")
|
||||||
})
|
})
|
||||||
export const Links = z.object({
|
export const Links = z.object({
|
||||||
color: z.string().toLowerCase().length(6).regex(/^[a-f0-9]+$/,"illegal characters").optional(),
|
color: RGBHex.optional(),
|
||||||
largeImage: z.boolean().default(false)
|
largeImage: z.boolean().default(false)
|
||||||
})
|
})
|
||||||
export const User = z.object({
|
export const User = z.object({
|
||||||
|
|
3
src/server/lib/schemas/misc.ts
Normal file
3
src/server/lib/schemas/misc.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
export const RGBHex = z.string().toLowerCase().length(6).regex(/^[a-f0-9]+$/,"illegal characters")
|
|
@ -13,6 +13,7 @@ import pkg from "../../../../lib/package.js"
|
||||||
import { type StatusCode } from "hono/utils/http-status"
|
import { type StatusCode } from "hono/utils/http-status"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { FileSchemas } from "../../../../lib/schemas/index.js"
|
import { FileSchemas } from "../../../../lib/schemas/index.js"
|
||||||
|
import config from "../../../../lib/config.js"
|
||||||
|
|
||||||
const router = new Hono<{
|
const router = new Hono<{
|
||||||
Variables: {
|
Variables: {
|
||||||
|
@ -54,6 +55,9 @@ export default function(files: Files) {
|
||||||
if (!ctx.req.raw.body)
|
if (!ctx.req.raw.body)
|
||||||
return resolve(ctx.body("body must be supplied", 400))
|
return resolve(ctx.body("body must be supplied", 400))
|
||||||
|
|
||||||
|
if (config.accounts.requiredForUpload && !acc)
|
||||||
|
return resolve(ctx.body("instance requires you to be authenticated to upload files", 401))
|
||||||
|
|
||||||
let file = files.createWriteStream(acc?.id)
|
let file = files.createWriteStream(acc?.id)
|
||||||
|
|
||||||
file
|
file
|
||||||
|
|
Loading…
Reference in a new issue