Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
83e344b
📦️ build(biome): update to biome v2 and migrate configuration
koutyuke Oct 27, 2025
d72f115
🗑️ chore(biome): remove obsolete biome.json and update configurations…
koutyuke Dec 31, 2025
41fe553
🔧 chore(catalog): apply new lint rule
koutyuke Dec 31, 2025
df4c0ed
🔧 chore(lefthook): simplify biome check command by removing unnecessa…
koutyuke Dec 31, 2025
0c8a700
🗑️ chore(biome): remove outdated comment regarding biome resolution i…
koutyuke Dec 31, 2025
3c92026
🔧 chore(auth): update various email and user profile handling compone…
koutyuke Dec 31, 2025
7516c16
🔧 chore(web): update biome.json includes path, enhance tailwind.confi…
koutyuke Dec 31, 2025
e75ee97
🔧 chore(mobile): update various components for improved clarity and f…
koutyuke Dec 31, 2025
734d9b6
🔧 chore(argon2id): add missing import statement in index.test.ts for …
koutyuke Dec 31, 2025
bb1d21f
🔧 chore(http, result): reorder exports for improved clarity and consi…
koutyuke Dec 31, 2025
749ab56
🔧 chore(http, result): update error handling and improve comments for…
koutyuke Dec 31, 2025
4014ae2
🔧 chore(design-tokens): refactor exports in index.ts for consistency,…
koutyuke Dec 31, 2025
7230bff
🔧 chore(tailwind-helpers): refactor index.ts to streamline exports an…
koutyuke Dec 31, 2025
59c7987
🔧 chore(treaty-fetch): refactor imports in fetch.ts to enhance clarit…
koutyuke Dec 31, 2025
b14220b
🔧 chore(tailwind-config): refactor import statements in global.css an…
koutyuke Dec 31, 2025
9321fba
🔧 chore(ui): enhance component imports and configurations for improve…
koutyuke Dec 31, 2025
b5632ab
🔧 chore(dependencies): update @types/react-dom to version 19.1.10 in …
koutyuke Dec 31, 2025
6afaf35
🔧 chore(vscode): update default formatters for JSON and JSONC files t…
koutyuke Dec 31, 2025
8b2aad9
🔧 chore(biome): update ignore patterns in biome.json and biome.jsonc …
koutyuke Dec 31, 2025
41dc2b2
🔧 chore(treaty-fetch): reorder import statements in index.d.ts for im…
koutyuke Dec 31, 2025
784285e
🔧 chore(biome): rename to .jsonc
koutyuke Dec 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
50 changes: 14 additions & 36 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
"editor.defaultFormatter": "biomejs.biome"
},
"[properties]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
Expand All @@ -20,20 +23,15 @@
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"biome.requireConfiguration": true,
"commit-message-editor.dynamicTemplate": [
"{type}{scope}{breaking_change_exclamation}: {description}",
"",
"{body}",
"",
"{breaking_change_footer}{footer}"
],
"commit-message-editor.staticTemplate": [
"label: emoji (scope) short-description",
"",
"body",
"",
"footer"
],
"commit-message-editor.staticTemplate": ["label: emoji (scope) short-description", "", "body", "", "footer"],
"commit-message-editor.tokens": [
{
"combobox": true,
Expand Down Expand Up @@ -157,40 +155,20 @@
],
"commit-message-editor.view.defaultView": "form",
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.fixAll.biome": "explicit",
"source.organizeImports.biome": "explicit"
},
"editor.defaultFormatter": "biomejs.biome",
"npm.packageManager": "bun",
"svg.preview.background": "custom",
"tailwindCSS.experimental.classRegex": [
[
"clsx\\(([^)]*)\\)",
"(?:'|\"|`)([^']*)(?:'|\"|`)"
],
[
"tv\\(([\\s\\S]*?)\\);",
"[\"']([^\"']*).*?[\"']"
],
[
"twMerge\\(([\\s\\S]*?)\\);",
"[\"']([^\"']*).*?[\"']"
],
[
"tv\\(([\\s\\S]*?)\\)",
"[\"']([^\"']*).*?[\"']"
],
[
"twMerge\\(([\\s\\S]*?)\\)",
"[\"']([^\"']*).*?[\"']"
],
[
"[A-Za-z_][A-Za-z0-9_]*ClassName\\s*[:=]\\s*{?[\"'`]([^\"'`]*).*?[\"'`]"
],
[
"[A-Za-z_][A-Za-z0-9_]*ClassName\\s*[:=]\\s*{?`([^`]*).*?`",
"[\"']([^\"']*).*?[\"']"
]
["clsx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"],
["tv\\(([\\s\\S]*?)\\);", "[\"']([^\"']*).*?[\"']"],
["twMerge\\(([\\s\\S]*?)\\);", "[\"']([^\"']*).*?[\"']"],
["tv\\(([\\s\\S]*?)\\)", "[\"']([^\"']*).*?[\"']"],
["twMerge\\(([\\s\\S]*?)\\)", "[\"']([^\"']*).*?[\"']"],
["[A-Za-z_][A-Za-z0-9_]*ClassName\\s*[:=]\\s*{?[\"'`]([^\"'`]*).*?[\"'`]"],
["[A-Za-z_][A-Za-z0-9_]*ClassName\\s*[:=]\\s*{?`([^`]*).*?`", "[\"']([^\"']*).*?[\"']"]
],
"tailwindCSS.includeLanguages": {
"typescript": "javascript",
Expand Down
20 changes: 20 additions & 0 deletions apps/api/biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "../../node_modules/@biomejs/biome/configuration_schema.json",
"root": false,
"extends": "//",
"files": {
"includes": ["!!src/core/infra/crypto/argon2id/bin", "!drizzle", "!types"]
},
"overrides": [
{
"includes": ["src/routes/index.ts"],
"linter": {
"rules": {
"style": {
"noDefaultExport": "off"
}
}
}
}
]
}
8 changes: 5 additions & 3 deletions apps/api/src/core/adapters/gateways/email/email.gateway.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { render } from "@react-email/render";
import { Resend } from "resend";
import { verificationEmailTemplate } from "./mail-context";

import type { ReactElement } from "react";
import { type CreateEmailOptions, type CreateEmailRequestOptions, type CreateEmailResponse, Resend } from "resend";
import type { CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse } from "resend";
import type { IEmailGateway } from "../../../ports/gateways";
import { verificationEmailTemplate } from "./mail-context";
import type { EmailRenderOptions, RequireAtLeastOne } from "./type";

export class EmailGateway implements IEmailGateway {
Expand All @@ -23,7 +25,7 @@ export class EmailGateway implements IEmailGateway {
}

const contents = await this.render(payload);
// biome-ignore lint/suspicious/noConsoleLog: <explanation>
// biome-ignore lint/suspicious/noConsole: Development mode logging for email preview
console.log(
"[Email: Development] Email will not be sent. Email content is as follows:\n\n",
`to: ${payload.to}\n`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { verificationEmailTemplate } from "./verification";

export type { EmailContext } from "./type";
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DEFAULT_EMAIL_ADDRESS } from "@mona-ca/core/email";

import type { EmailContext } from "./type";

export const verificationEmailTemplate = (email: string, code: string): EmailContext => {
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/core/di/container.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { EmailGateway } from "../adapters/gateways/email";
import { TurnstileGateway } from "../adapters/gateways/turnstile";
import type { CloudflareBindings, EnvVariables } from "../infra/config/env";
import { CryptoRandomService, HmacSha256Service, PasswordHashingService, TokenSecretService } from "../infra/crypto";
import { DrizzleService } from "../infra/drizzle";

import type { CloudflareBindings, EnvVariables } from "../infra/config/env";
import type { IEmailGateway, ITurnstileGateway } from "../ports/gateways";
import type { ICryptoRandomService, IHmacService, IPasswordHashingService, ITokenSecretService } from "../ports/system";
import type { ICoreDIContainer } from "./container.interface";
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/core/di/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export type { ICoreDIContainer } from "./container.interface";
export { CoreDIContainer } from "./container";

export type { ICoreDIContainer } from "./container.interface";
3 changes: 2 additions & 1 deletion apps/api/src/core/domain/value-objects/client-platform.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Brand } from "@mona-ca/core/types";
import { t } from "elysia";

import type { Brand } from "@mona-ca/core/types";

export type RawMobilePlatform = "mobile";
export type MobilePlatform = Brand<"ClientPlatform", RawMobilePlatform>;

Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/core/domain/value-objects/gender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Brand } from "@mona-ca/core/types";
import { t } from "elysia";

import type { Brand } from "@mona-ca/core/types";

export type MaleGender = Brand<"Gender", "male">;
export type FemaleGender = Brand<"Gender", "female">;
export type Gender = MaleGender | FemaleGender;
Expand Down
16 changes: 8 additions & 8 deletions apps/api/src/core/domain/value-objects/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export {
newClientPlatform,
clientPlatformSchema,
newMobilePlatform,
newWebPlatform,
isMobilePlatform,
isWebPlatform,
mobilePlatformSchema,
newClientPlatform,
newMobilePlatform,
newWebPlatform,
webPlatformSchema,
} from "./client-platform";
export {
newMaleGender,
newFemaleGender,
newGender,
maleGenderSchema,
femaleGenderSchema,
genderSchema,
maleGenderSchema,
newFemaleGender,
newGender,
newMaleGender,
} from "./gender";
export { newUserId } from "./ids";

Expand All @@ -24,8 +24,8 @@ export type {
WebPlatform,
} from "./client-platform";
export type {
MaleGender,
FemaleGender,
Gender,
MaleGender,
} from "./gender";
export type { UserId } from "./ids";
3 changes: 2 additions & 1 deletion apps/api/src/core/infra/config/env/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { env as productionEnv } from "cloudflare:workers";
import type { CloudflareBindings, Env, EnvVariables } from "./type";
import { validateEnv } from "./validation";

import type { CloudflareBindings, Env, EnvVariables } from "./type";

const getEnv = (): {
env: Readonly<Env>;
envVariables: Readonly<EnvVariables>;
Expand Down
22 changes: 11 additions & 11 deletions apps/api/src/core/infra/config/env/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
export { cloudflareBindings, env, envVariables } from "./env";
export {
EnvVariablesSchema,
PublicSchema,
HMACSecretSchema,
OAuthProviderSchema,
PepperSchema,
PublicSchema,
ResendSchema,
UpstashRedisSchema,
TurnstileSchema,
HMACSecretSchema,
UpstashRedisSchema,
} from "./schema";
export { env, envVariables, cloudflareBindings } from "./env";

export type {
PublicEnv,
PepperEnv,
ResendEnv,
UpstashRedisEnv,
TurnstileEnv,
OAuthProviderEnv,
EnvVariables,
CloudflareBindings,
Env,
EnvVariables,
HMACSecretEnv,
OAuthProviderEnv,
PepperEnv,
PublicEnv,
ResendEnv,
TurnstileEnv,
UpstashRedisEnv,
} from "./type";
2 changes: 2 additions & 0 deletions apps/api/src/core/infra/config/env/validation.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Value } from "@sinclair/typebox/value";
import { EnvVariablesSchema } from "./schema";

import type { EnvVariables } from "./type";

export const validateEnv = (envVariables: EnvVariables) => {
const preparedEnv = Value.Clean(EnvVariablesSchema, Value.Convert(EnvVariablesSchema, envVariables));

if (!Value.Check(EnvVariablesSchema, preparedEnv)) {
// biome-ignore lint/suspicious/noConsole: Critical error logging before throwing
console.error("🚨 Invalid environment variables");
throw new Error("🚨 Invalid environment variables");
}
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/core/infra/crypto/argon2id/argon2id.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IArgon2idService } from "../../../ports/system";
import { HashOptions, hash, verify } from "./bin/wasm_argon2";

import type { IArgon2idService } from "../../../ports/system";

export class Argon2idService implements IArgon2idService {
private readonly hashOption: HashOptions | undefined;

Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/core/infra/crypto/crypto-random.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// ref: https://crypto.oslojs.dev/examples/random-values

import {
type RandomReader,
generateRandomIntegerNumber as osloGenerateRandomIntegerNumber,
generateRandomString as osloGenerateRandomString,
} from "@oslojs/crypto/random";

import type { RandomReader } from "@oslojs/crypto/random";
import type { ICryptoRandomService, RandomStringOptions } from "../../ports/system";

const LOWER = "abcdefghijklmnopqrstuvwxyz";
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/core/infra/crypto/hmac-sha-256.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createHmac } from "node:crypto";
import { timingSafeStringEqual } from "../../lib/security";

import type { IHmacService, MacEncoding, MacOptions } from "../../ports/system";

export class HmacSha256Service implements IHmacService {
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/core/infra/crypto/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { TokenSecretService } from "./token-secret.service";
export { PasswordHashingService } from "./password-hashing.service";
export { HmacSha256Service } from "./hmac-sha-256.service";
export { CryptoRandomService } from "./crypto-random.service";
export { HmacSha256Service } from "./hmac-sha-256.service";
export { PasswordHashingService } from "./password-hashing.service";
export { TokenSecretService } from "./token-secret.service";
3 changes: 2 additions & 1 deletion apps/api/src/core/infra/crypto/password-hashing.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IPasswordHashingService } from "../../ports/system";
import { Argon2idService } from "./argon2id";

import type { IPasswordHashingService } from "../../ports/system";

export class PasswordHashingService implements IPasswordHashingService {
private readonly argon2idService: Argon2idService;
private readonly pepper: string;
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/core/infra/crypto/token-secret.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { timingSafeEqual } from "node:crypto";
import { sha256 } from "@oslojs/crypto/sha2";
import { encodeBase32LowerCaseNoPadding } from "@oslojs/encoding";

import type { ITokenSecretService } from "../../ports/system";

export class TokenSecretService implements ITokenSecretService {
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/core/infra/drizzle/drizzle.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { drizzle } from "drizzle-orm/d1";
import type { DrizzleD1Database } from "drizzle-orm/d1";
import * as schema from "./schema";

import type { DrizzleD1Database } from "drizzle-orm/d1";

export class DrizzleService {
public db: DrizzleD1Database<typeof schema>;
public schema = schema;
Expand Down
10 changes: 5 additions & 5 deletions apps/api/src/core/infra/drizzle/schema/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export { providerAccountsTable } from "./provider-accounts.table";
export { sessionsTable } from "./sessions.table";
export { usersTable } from "./users.table";
export { accountLinkRequestsTable } from "./account-link-requests.table";
export { emailVerificationRequestsTable } from "./email-verification-requests.table";
export { passwordResetSessionsTable } from "./password-reset-sessions.table";
export { accountLinkRequestsTable } from "./account-link-requests.table";
export { signupSessionsTable } from "./signup-sessions.table";
export { providerAccountsTable } from "./provider-accounts.table";
export { providerLinkRequestsTable } from "./provider-link-requests.table";
export { sessionsTable } from "./sessions.table";
export { signupSessionsTable } from "./signup-sessions.table";
export { usersTable } from "./users.table";
2 changes: 1 addition & 1 deletion apps/api/src/core/lib/encoding/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export {
encodeBase64URLSafe,
decodeBase64URLSafe,
encodeBase64URLSafe,
} from "./base64-url-safe";
4 changes: 2 additions & 2 deletions apps/api/src/core/lib/http/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { getIP, DEVELOPMENT_IP_ADDRESS } from "./get-ip";
export { PROD_ORIGIN_REGEX, DEV_ORIGIN_REGEX } from "./cors";
export { DEV_ORIGIN_REGEX, PROD_ORIGIN_REGEX } from "./cors";
export { DEVELOPMENT_IP_ADDRESS, getIP } from "./get-ip";
3 changes: 2 additions & 1 deletion apps/api/src/core/lib/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { StringEnum } from "./schema";
export type { JsonValue, JsonObject, JsonArray, JsonPrimitive } from "./json";

export type { JsonArray, JsonObject, JsonPrimitive, JsonValue } from "./json";
4 changes: 3 additions & 1 deletion apps/api/src/core/lib/types/schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Kind, type SchemaOptions, Type, TypeRegistry } from "@sinclair/typebox";
import { Kind, Type, TypeRegistry } from "@sinclair/typebox";
import { DefaultErrorFunction, SetErrorFunction, ValueErrorType } from "@sinclair/typebox/errors";

import type { SchemaOptions } from "@sinclair/typebox";

TypeRegistry.Set("StringEnum", (schema: { enum: string[] }, value: unknown) => {
return typeof value === "string" && schema.enum.includes(value);
});
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/core/ports/gateways/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type { IEmailGateway } from "./email.gateway.interface";
export type {
ITurnstileGateway,
TurnstileResult,
TurnstileErrorCodes,
TurnstileResult,
} from "./turnstile.gateway.interface";
export type { IEmailGateway } from "./email.gateway.interface";
4 changes: 2 additions & 2 deletions apps/api/src/core/ports/system/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type { IArgon2idService } from "./argon2id.service.interface";
export type { ICryptoRandomService, RandomStringOptions } from "./crypto-random.service.interface";
export type { MacEncoding, MacOptions, IHmacService } from "./hmac.service.interface";
export type { IHmacService, MacEncoding, MacOptions } from "./hmac.service.interface";
export type { IPasswordHashingService } from "./password-hashing.service.interface";
export type { ITokenSecretService } from "./token-secret.service.interface";
export type { IArgon2idService } from "./argon2id.service.interface";
Loading