Skip to content

Commit 86d80ca

Browse files
committed
feat: replace nanoid import with customAlphabet for consistent ID generation across routes
1 parent 86be237 commit 86d80ca

5 files changed

Lines changed: 10 additions & 5 deletions

File tree

services/backend/src/db.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { MesahubClient } from '@mesahub/client';
2-
import { nanoid } from 'nanoid';
2+
import { customAlphabet } from 'nanoid';
3+
const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 21);
34
import { env } from './env.js';
45
import { parseMesahubUrl } from './lib/mesahub-url.js';
56
import { LAYOUTS } from './emails/render.js';

services/backend/src/routes/domains.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Hono } from 'hono';
22
import { zValidator } from '@hono/zod-validator';
33
import { z } from 'zod';
4-
import { nanoid } from 'nanoid';
4+
import { customAlphabet } from 'nanoid';
5+
const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 21);
56
import { domains, deleteDomainCascade } from '../db.js';
67
import { CloudflareApiError } from '../services/cloudflare.js';
78
import { createSendingSubdomain, listSendingSubdomains, getSubdomainDnsRecords, getSendingSubdomain, getZoneByHostname } from '../services/cloudflare.js';

services/backend/src/routes/keys.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { Hono } from 'hono';
22
import { zValidator } from '@hono/zod-validator';
33
import { z } from 'zod';
44
import { createHash, randomBytes } from 'node:crypto';
5-
import { nanoid } from 'nanoid';
5+
import { customAlphabet } from 'nanoid';
6+
const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 21);
67
import { apiKeys, apiKeyDomains } from '../db.js';
78

89
const app = new Hono();

services/backend/src/routes/send.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Hono } from 'hono';
22
import { zValidator } from '@hono/zod-validator';
33
import { z } from 'zod';
4-
import { nanoid } from 'nanoid';
4+
import { customAlphabet } from 'nanoid';
5+
const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 21);
56
import { db, emailLogs, templates } from '../db.js';
67
import { sendEmail } from '../services/cloudflare.js';
78
import { sendEmailViaSmtp } from '../services/smtp.js';

services/backend/src/routes/templates.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Hono } from 'hono';
22
import { zValidator } from '@hono/zod-validator';
33
import { z } from 'zod';
4-
import { nanoid } from 'nanoid';
4+
import { customAlphabet } from 'nanoid';
5+
const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 21);
56
import { db, templates } from '../db.js';
67
import { LAYOUTS, renderLayout } from '../emails/render.js';
78
import type { TemplateRow } from '../db.js';

0 commit comments

Comments
 (0)