diff --git a/server/domain/task/model/taskMethod.ts b/server/domain/task/model/taskMethod.ts index f2fc211..8bc9230 100644 --- a/server/domain/task/model/taskMethod.ts +++ b/server/domain/task/model/taskMethod.ts @@ -1,13 +1,13 @@ import type { TaskCreateVal, TaskEntity, TaskUpdateVal } from 'api/@types/task'; import assert from 'assert'; -import { randomUUID } from 'crypto'; import { deletableTaskIdParser, taskIdParser } from 'service/idParsers'; +import { ulid } from 'ulid'; import type { TaskDeleteVal } from './taskEntity'; export const taskMethod = { create: (val: TaskCreateVal): TaskEntity => { return { - id: taskIdParser.parse(randomUUID()), + id: taskIdParser.parse(ulid()), done: false, label: val.label, createdTime: Date.now(), diff --git a/server/package-lock.json b/server/package-lock.json index 4c9e1db..33eef76 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -14,6 +14,7 @@ "dotenv": "^16.4.5", "fastify": "^4.26.2", "nodemailer": "^6.9.13", + "ulid": "^2.3.0", "velona": "^0.8.0", "zod": "^3.23.6" }, @@ -4692,6 +4693,14 @@ "node": ">=14.17" } }, + "node_modules/ulid": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/ulid/-/ulid-2.3.0.tgz", + "integrity": "sha512-keqHubrlpvT6G2wH0OEfSW4mquYRcbe/J8NMmveoQOjUqmo+hXtO+ORCpWhdbZ7k72UtY61BL7haGxW6enBnjw==", + "bin": { + "ulid": "bin/cli.js" + } + }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -8384,6 +8393,11 @@ "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true }, + "ulid": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/ulid/-/ulid-2.3.0.tgz", + "integrity": "sha512-keqHubrlpvT6G2wH0OEfSW4mquYRcbe/J8NMmveoQOjUqmo+hXtO+ORCpWhdbZ7k72UtY61BL7haGxW6enBnjw==" + }, "unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", diff --git a/server/package.json b/server/package.json index ca9b2ea..fd76c5a 100644 --- a/server/package.json +++ b/server/package.json @@ -24,6 +24,7 @@ "dotenv": "^16.4.5", "fastify": "^4.26.2", "nodemailer": "^6.9.13", + "ulid": "^2.3.0", "velona": "^0.8.0", "zod": "^3.23.6" }, diff --git a/server/service/sendMail.ts b/server/service/sendMail.ts index 231c029..3d386b1 100644 --- a/server/service/sendMail.ts +++ b/server/service/sendMail.ts @@ -1,10 +1,10 @@ import { APP_NAME } from 'api/@constants'; import assert from 'assert'; -import { randomUUID } from 'crypto'; import { InbucketAPIClient } from 'inbucket-js-client'; import { createTransport } from 'nodemailer'; import type Mail from 'nodemailer/lib/mailer'; import type SMTPTransport from 'nodemailer/lib/smtp-transport'; +import { ulid } from 'ulid'; import { SMTP_HOST, SMTP_PASS, SMTP_PORT, SMTP_USER } from './envValues'; const transport = createTransport({ @@ -33,7 +33,7 @@ if (import.meta.vitest) { const inbucketClient = new InbucketAPIClient(process.env.INBUCKET_URL); test('sendMail', async () => { - const from = `${randomUUID()}@localhost`; + const from = `${ulid()}@localhost`; const text = 'aaa'; await sendMail({ to: { name: 'hoge', address: 'aa@example.com' }, subject: 'test', text });