Skip to content

Commit

Permalink
feat: use ulid for primary key
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed May 23, 2024
1 parent 5a17f9c commit 82de534
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/domain/task/model/taskMethod.ts
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
14 changes: 14 additions & 0 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions server/service/sendMail.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down Expand Up @@ -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: '[email protected]' }, subject: 'test', text });
Expand Down

0 comments on commit 82de534

Please sign in to comment.