Compare commits

..

3 Commits

Author SHA1 Message Date
Henry
6dd1d3b6e2 feat: enhance label router with consistent output 2025-07-07 22:15:11 +01:00
Rees Morris
fdfd1f3d03 feat: add S3_FORCE_PATH_STYLE configuration for MinIO compatibility (#100)
* feat: add S3_FORCE_PATH_STYLE configuration for MinIO compatibility

* docs: add S3_FORCE_PATH_STYLE to env example
2025-07-07 21:06:51 +01:00
Henry
392be38f10 feat: improve mobile support on ios (#99)
* fix: add min width to dashboard

* fix: display theme background and set dynamic viewport height

* fix: prevent zooming on ios

* fix: enable scroll on card page
2025-07-03 09:12:06 +01:00
11 changed files with 50 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ S3_REGION=
S3_ENDPOINT=
S3_ACCESS_KEY_ID=
S3_SECRET_ACCESS_KEY=
S3_FORCE_PATH_STYLE=
NEXT_PUBLIC_STORAGE_URL=
NEXT_PUBLIC_AVATAR_BUCKET_NAME=
NEXT_PUBLIC_STORAGE_DOMAIN=

View File

@@ -162,6 +162,7 @@ pnpm dev
| `S3_ENDPOINT` | S3 endpoint URL | For file uploads | `https://xxx.r2.cloudflarestorage.com` |
| `S3_ACCESS_KEY_ID` | S3 access key | For file uploads | `xxx` |
| `S3_SECRET_ACCESS_KEY` | S3 secret key | For file uploads | `xxx` |
| `S3_FORCE_PATH_STYLE` | Use path-style URLs for S3 | For file uploads | `true` |
| `NEXT_PUBLIC_STORAGE_URL` | Storage service URL | For file uploads | `https://storage.kanbn.com` |
| `NEXT_PUBLIC_STORAGE_DOMAIN` | Storage domain name | For file uploads | `kanbn.com` |
| `NEXT_PUBLIC_AVATAR_BUCKET_NAME` | S3 bucket name for avatars | For file uploads | `avatars` |

View File

@@ -31,9 +31,12 @@ const config = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: `*.${env("NEXT_PUBLIC_STORAGE_DOMAIN")}`,
hostname: process.env.S3_FORCE_PATH_STYLE === "true"
? `${env("NEXT_PUBLIC_STORAGE_DOMAIN")}`
: `*.${env("NEXT_PUBLIC_STORAGE_DOMAIN")}`,
},
{
protocol: "http",

View File

@@ -69,6 +69,7 @@ export const env = createEnv({
S3_SECRET_ACCESS_KEY: z.string().optional(),
S3_REGION: z.string().optional(),
S3_ENDPOINT: z.string().optional(),
S3_FORCE_PATH_STYLE: z.string().optional(),
EMAIL_FROM: z.string().optional(),
},

View File

@@ -46,6 +46,7 @@ export default async function handler(
const client = new S3Client({
region: env.S3_REGION ?? "",
endpoint: env.S3_ENDPOINT ?? "",
forcePathStyle: env.S3_FORCE_PATH_STYLE === "true",
credentials: {
accessKeyId: env.S3_ACCESS_KEY_ID ?? "",
secretAccessKey: env.S3_SECRET_ACCESS_KEY ?? "",
@@ -58,6 +59,7 @@ export default async function handler(
new PutObjectCommand({
Bucket: nextRuntimeEnv("NEXT_PUBLIC_AVATAR_BUCKET_NAME") ?? "",
Key: filename,
ACL: "public-read",
}),
);

View File

@@ -36,6 +36,7 @@ services:
- S3_SECRET_ACCESS_KEY=${S3_SECRET_ACCESS_KEY}
- S3_REGION=${S3_REGION}
- S3_ENDPOINT=${S3_ENDPOINT}
- S3_FORCE_PATH_STYLE=${S3_FORCE_PATH_STYLE}
- NEXT_PUBLIC_STORAGE_URL=${NEXT_PUBLIC_STORAGE_URL}
- NEXT_PUBLIC_AVATAR_BUCKET_NAME=${NEXT_PUBLIC_AVATAR_BUCKET_NAME}
- NEXT_PUBLIC_STORAGE_DOMAIN=${NEXT_PUBLIC_STORAGE_DOMAIN}

View File

@@ -30,6 +30,7 @@ services:
- S3_SECRET_ACCESS_KEY=${S3_SECRET_ACCESS_KEY}
- S3_REGION=${S3_REGION}
- S3_ENDPOINT=${S3_ENDPOINT}
- S3_FORCE_PATH_STYLE=${S3_FORCE_PATH_STYLE}
- NEXT_PUBLIC_STORAGE_URL=${NEXT_PUBLIC_STORAGE_URL}
- NEXT_PUBLIC_AVATAR_BUCKET_NAME=${NEXT_PUBLIC_AVATAR_BUCKET_NAME}
- NEXT_PUBLIC_STORAGE_DOMAIN=${NEXT_PUBLIC_STORAGE_DOMAIN}

View File

@@ -8,6 +8,12 @@ import * as labelRepo from "@kan/db/repository/label.repo";
import { createTRPCRouter, protectedProcedure } from "../trpc";
import { assertUserInWorkspace } from "../utils/auth";
const labelSchema = z.object({
publicId: z.string(),
name: z.string(),
colourCode: z.string().nullable(),
});
export const labelRouter = createTRPCRouter({
byPublicId: protectedProcedure
.meta({
@@ -21,7 +27,7 @@ export const labelRouter = createTRPCRouter({
},
})
.input(z.object({ labelPublicId: z.string().min(12) }))
.output(z.custom<Awaited<ReturnType<typeof labelRepo.getByPublicId>>>())
.output(labelSchema)
.query(async ({ ctx, input }) => {
const userId = ctx.user?.id;
@@ -52,7 +58,11 @@ export const labelRouter = createTRPCRouter({
code: "NOT_FOUND",
});
return result;
return {
publicId: result.publicId,
name: result.name,
colourCode: result.colourCode,
};
}),
create: protectedProcedure
.meta({
@@ -72,7 +82,7 @@ export const labelRouter = createTRPCRouter({
colourCode: z.string().length(7),
}),
)
.output(z.custom<Awaited<ReturnType<typeof labelRepo.create>>>())
.output(labelSchema)
.mutation(async ({ ctx, input }) => {
const userId = ctx.user?.id;
@@ -108,7 +118,11 @@ export const labelRouter = createTRPCRouter({
code: "INTERNAL_SERVER_ERROR",
});
return result;
return {
publicId: result.publicId,
name: result.name,
colourCode: result.colourCode,
};
}),
update: protectedProcedure
.meta({
@@ -128,7 +142,7 @@ export const labelRouter = createTRPCRouter({
colourCode: z.string().length(7),
}),
)
.output(z.custom<Awaited<ReturnType<typeof labelRepo.update>>>())
.output(labelSchema)
.mutation(async ({ ctx, input }) => {
const userId = ctx.user?.id;
@@ -153,7 +167,17 @@ export const labelRouter = createTRPCRouter({
const result = await labelRepo.update(ctx.db, input);
return result;
if (!result)
throw new TRPCError({
message: `Failed to update label`,
code: "INTERNAL_SERVER_ERROR",
});
return {
publicId: result.publicId,
name: result.name,
colourCode: result.colourCode,
};
}),
delete: protectedProcedure
.meta({

View File

@@ -181,6 +181,7 @@ export const initAuth = (db: dbClient) => {
const client = new S3Client({
region: env("S3_REGION") ?? "",
endpoint: env("S3_ENDPOINT") ?? "",
forcePathStyle: env("S3_FORCE_PATH_STYLE") === "true",
credentials: {
accessKeyId: env("S3_ACCESS_KEY_ID") ?? "",
secretAccessKey: env("S3_SECRET_ACCESS_KEY") ?? "",

View File

@@ -23,7 +23,12 @@ export const create = async (
createdBy: labelInput.createdBy,
boardId: labelInput.boardId,
})
.returning({ id: labels.id });
.returning({
id: labels.id,
publicId: labels.publicId,
name: labels.name,
colourCode: labels.colourCode,
});
if (labelInput.cardId && result) {
await db.insert(cardsToLabels).values({
@@ -91,6 +96,7 @@ export const update = async (
.where(eq(labels.publicId, labelInput.labelPublicId))
.returning({
id: labels.id,
publicId: labels.publicId,
name: labels.name,
colourCode: labels.colourCode,
});

View File

@@ -106,6 +106,7 @@
"S3_ACCESS_KEY_ID",
"S3_SECRET_ACCESS_KEY",
"S3_ENDPOINT",
"S3_FORCE_PATH_STYLE",
"PORT",
"BETTER_AUTH_SECRET",
"BETTER_AUTH_TRUSTED_ORIGINS"