diff --git a/pkg/accounts/adaptor/controller/account.ts b/pkg/accounts/adaptor/controller/account.ts index 32052ad3..995b70d6 100644 --- a/pkg/accounts/adaptor/controller/account.ts +++ b/pkg/accounts/adaptor/controller/account.ts @@ -3,16 +3,16 @@ import { Option, Result } from '@mikuroxina/mini-fn'; import type { ID } from '../../../id/type.js'; import { type AccountID, type AccountName } from '../../model/account.js'; -import type { TokenVerifyService } from '../../service/accountVerifyToken.js'; -import type { AuthenticationService } from '../../service/authenticate.js'; +import type { AuthenticateAccountService } from '../../service/authenticateAccount.js'; import type { EditAccountService } from '../../service/editAccount.js'; import type { FetchAccountService } from '../../service/fetchAccount.js'; -import type { FollowService } from '../../service/follow.js'; -import type { FreezeService } from '../../service/freeze.js'; -import type { RegisterAccountService } from '../../service/register.js'; +import type { FollowAccountService } from '../../service/followAccount.js'; +import type { FreezeAccountService } from '../../service/freezeAccount.js'; +import type { RegisterAccountService } from '../../service/registerAccount.js'; import type { ResendVerifyTokenService } from '../../service/resendToken.js'; -import type { SilenceService } from '../../service/silence.js'; -import { type UnfollowService } from '../../service/unfollow.js'; +import type { SilenceAccountService } from '../../service/silenceAccount.js'; +import { type UnfollowAccountService } from '../../service/unfollowAccount.js'; +import type { VerifyAccountTokenService } from '../../service/verifyAccountToken.js'; import { type CreateAccountResponseSchema, type GetAccountResponseSchema, @@ -24,35 +24,35 @@ export class AccountController { private readonly registerAccountService: RegisterAccountService; private readonly editAccountService: EditAccountService; private readonly fetchAccountService: FetchAccountService; - private readonly freezeService: FreezeService; - private readonly tokenVerifyService: TokenVerifyService; - private readonly authenticationService: AuthenticationService; - private readonly silenceService: SilenceService; - private readonly followService: FollowService; - private readonly unFollowService: UnfollowService; + private readonly freezeAccountService: FreezeAccountService; + private readonly verifyAccountTokenService: VerifyAccountTokenService; + private readonly authenticateAccountService: AuthenticateAccountService; + private readonly silenceAccountService: SilenceAccountService; + private readonly followAccountService: FollowAccountService; + private readonly unfollowAccountService: UnfollowAccountService; private readonly resendTokenService: ResendVerifyTokenService; constructor(args: { registerAccountService: RegisterAccountService; editAccountService: EditAccountService; fetchAccountService: FetchAccountService; - freezeService: FreezeService; - tokenVerifyService: TokenVerifyService; - authenticationService: AuthenticationService; - silenceService: SilenceService; - followService: FollowService; - unFollowService: UnfollowService; + freezeAccountService: FreezeAccountService; + verifyAccountTokenService: VerifyAccountTokenService; + authenticateAccountService: AuthenticateAccountService; + silenceAccountService: SilenceAccountService; + followAccountService: FollowAccountService; + unfollowAccountService: UnfollowAccountService; resendTokenService: ResendVerifyTokenService; }) { this.registerAccountService = args.registerAccountService; this.editAccountService = args.editAccountService; this.fetchAccountService = args.fetchAccountService; - this.freezeService = args.freezeService; - this.tokenVerifyService = args.tokenVerifyService; - this.authenticationService = args.authenticationService; - this.silenceService = args.silenceService; - this.followService = args.followService; - this.unFollowService = args.unFollowService; + this.freezeAccountService = args.freezeAccountService; + this.verifyAccountTokenService = args.verifyAccountTokenService; + this.authenticateAccountService = args.authenticateAccountService; + this.silenceAccountService = args.silenceAccountService; + this.followAccountService = args.followAccountService; + this.unfollowAccountService = args.unfollowAccountService; this.resendTokenService = args.resendTokenService; } @@ -152,7 +152,7 @@ export class AccountController { } async freezeAccount(name: string): Promise> { - const res = await this.freezeService.setFreeze(name as AccountName); + const res = await this.freezeAccountService.setFreeze(name as AccountName); if (Result.isErr(res)) { return res; } @@ -161,7 +161,7 @@ export class AccountController { } async unFreezeAccount(name: string): Promise> { - const res = await this.freezeService.undoFreeze(name as AccountName); + const res = await this.freezeAccountService.undoFreeze(name as AccountName); if (Result.isErr(res)) { return res; } @@ -173,7 +173,7 @@ export class AccountController { name: string, token: string, ): Promise> { - const res = await this.tokenVerifyService.verify( + const res = await this.verifyAccountTokenService.verify( name as AccountName, token, ); @@ -249,7 +249,7 @@ export class AccountController { passphrase: string, ): Promise>> { // ToDo: Check Captcha token - const res = await this.authenticationService.handle( + const res = await this.authenticateAccountService.handle( name as AccountName, passphrase, ); @@ -265,7 +265,9 @@ export class AccountController { async silenceAccount(name: string): Promise> { // ToDo: check user's permission - const res = await this.silenceService.setSilence(name as AccountName); + const res = await this.silenceAccountService.setSilence( + name as AccountName, + ); if (Result.isErr(res)) { return res; } @@ -275,7 +277,9 @@ export class AccountController { async unSilenceAccount(name: string): Promise> { // ToDo: check user's permission - const res = await this.silenceService.undoSilence(name as AccountName); + const res = await this.silenceAccountService.undoSilence( + name as AccountName, + ); if (Result.isErr(res)) { return res; } @@ -285,7 +289,7 @@ export class AccountController { async followAccount(name: string): Promise> { // ToDo: get following account's name from request - const res = await this.followService.handle( + const res = await this.followAccountService.handle( '' as AccountName, name as AccountName, ); @@ -297,7 +301,7 @@ export class AccountController { } async unFollowAccount(name: string): Promise> { - const res = await this.unFollowService.handle( + const res = await this.unfollowAccountService.handle( name as AccountName, '' as AccountName, ); diff --git a/pkg/accounts/adaptor/repository/dummy.ts b/pkg/accounts/adaptor/repository/dummy.ts index 284bc3fd..1557d1f9 100644 --- a/pkg/accounts/adaptor/repository/dummy.ts +++ b/pkg/accounts/adaptor/repository/dummy.ts @@ -2,7 +2,7 @@ import { Option, Result } from '@mikuroxina/mini-fn'; import { type ID } from '../../../id/type.js'; import { type Account, type AccountID } from '../../model/account.js'; -import { type AccountFollow } from '../../model/follow.js'; +import { type AccountFollow } from '../../model/followAccount.js'; import type { InactiveAccount } from '../../model/inactiveAccount.js'; import type { AccountFollowRepository, diff --git a/pkg/accounts/adaptor/repository/prisma.ts b/pkg/accounts/adaptor/repository/prisma.ts index 0a3fa70f..62259d47 100644 --- a/pkg/accounts/adaptor/repository/prisma.ts +++ b/pkg/accounts/adaptor/repository/prisma.ts @@ -11,7 +11,7 @@ import { type AccountSilenced, type AccountStatus, } from '../../model/account.js'; -import { AccountFollow } from '../../model/follow.js'; +import { AccountFollow } from '../../model/followAccount.js'; import type { AccountFollowRepository, AccountRepository, diff --git a/pkg/accounts/mod.ts b/pkg/accounts/mod.ts index 775b167f..d8db91b2 100644 --- a/pkg/accounts/mod.ts +++ b/pkg/accounts/mod.ts @@ -25,19 +25,19 @@ import { UpdateAccountRoute, VerifyEmailRoute, } from './router.js'; -import { TokenVerifyService } from './service/accountVerifyToken.js'; -import { AuthenticationService } from './service/authenticate.js'; +import { AuthenticateAccountService } from './service/authenticateAccount.js'; import { EditAccountService } from './service/editAccount.js'; import { EtagVerifyService } from './service/etagGenerateVerify.js'; import { FetchAccountService } from './service/fetchAccount.js'; -import { FollowService } from './service/follow.js'; -import { FreezeService } from './service/freeze.js'; -import { RegisterAccountService } from './service/register.js'; +import { FollowAccountService } from './service/followAccount.js'; +import { FreezeAccountService } from './service/freezeAccount.js'; +import { RegisterAccountService } from './service/registerAccount.js'; import { ResendVerifyTokenService } from './service/resendToken.js'; import { DummySendNotificationService } from './service/sendNotification.js'; -import { SilenceService } from './service/silence.js'; +import { SilenceAccountService } from './service/silenceAccount.js'; import { TokenGenerator } from './service/tokenGenerator.js'; -import { UnfollowService } from './service/unfollow.js'; +import { UnfollowAccountService } from './service/unfollowAccount.js'; +import { VerifyAccountTokenService } from './service/verifyAccountToken.js'; export const accounts = new OpenAPIHono(); const accountRepository = new InMemoryAccountRepository(); @@ -53,7 +53,7 @@ const idGenerator = new SnowflakeIDGenerator(0, new Clock()); const passwordEncoder = new Argon2idPasswordEncoder(); export const controller = new AccountController({ - authenticationService: new AuthenticationService({ + authenticateAccountService: new AuthenticateAccountService({ accountRepository: accountRepository, tokenGenerator: tokenGenerator, passwordEncoder: passwordEncoder, @@ -64,32 +64,35 @@ export const controller = new AccountController({ passwordEncoder, ), fetchAccountService: new FetchAccountService(accountRepository), - followService: new FollowService(accountFollowRepository, accountRepository), - freezeService: new FreezeService(accountRepository), + followAccountService: new FollowAccountService( + accountFollowRepository, + accountRepository, + ), + freezeAccountService: new FreezeAccountService(accountRepository), registerAccountService: new RegisterAccountService({ repository: accountRepository, idGenerator: idGenerator, passwordEncoder: passwordEncoder, sendNotification: new DummySendNotificationService(), - verifyTokenService: new TokenVerifyService( + verifyAccountTokenService: new VerifyAccountTokenService( accountVerifyTokenRepository, accountRepository, new Clock(), ), }), - silenceService: new SilenceService(accountRepository), - tokenVerifyService: new TokenVerifyService( + silenceAccountService: new SilenceAccountService(accountRepository), + verifyAccountTokenService: new VerifyAccountTokenService( accountVerifyTokenRepository, accountRepository, new Clock(), ), - unFollowService: new UnfollowService( + unfollowAccountService: new UnfollowAccountService( accountFollowRepository, accountRepository, ), resendTokenService: new ResendVerifyTokenService( accountRepository, - new TokenVerifyService( + new VerifyAccountTokenService( accountVerifyTokenRepository, accountRepository, new Clock(), diff --git a/pkg/accounts/model/follow.test.ts b/pkg/accounts/model/followAccount.test.ts similarity index 90% rename from pkg/accounts/model/follow.test.ts rename to pkg/accounts/model/followAccount.test.ts index 774bdd15..d9c57982 100644 --- a/pkg/accounts/model/follow.test.ts +++ b/pkg/accounts/model/followAccount.test.ts @@ -3,7 +3,10 @@ import { describe, expect, it } from 'vitest'; import type { ID } from '../../id/type.js'; import type { AccountID } from './account.js'; -import { AccountFollow, type CreateAccountFollowArgs } from './follow.js'; +import { + AccountFollow, + type CreateAccountFollowArgs, +} from './followAccount.js'; describe('AccountFollow', () => { it('generate new instance', () => { diff --git a/pkg/accounts/model/follow.ts b/pkg/accounts/model/followAccount.ts similarity index 100% rename from pkg/accounts/model/follow.ts rename to pkg/accounts/model/followAccount.ts diff --git a/pkg/accounts/model/repository.ts b/pkg/accounts/model/repository.ts index b20db847..4d557999 100644 --- a/pkg/accounts/model/repository.ts +++ b/pkg/accounts/model/repository.ts @@ -3,7 +3,7 @@ import type { Option, Result } from '@mikuroxina/mini-fn'; import { type ID } from '../../id/type.js'; import type { Account } from './account.js'; import { type AccountID } from './account.js'; -import type { AccountFollow } from './follow.js'; +import type { AccountFollow } from './followAccount.js'; import type { InactiveAccount } from './inactiveAccount.js'; export interface AccountRepository { diff --git a/pkg/accounts/service/authenticate.test.ts b/pkg/accounts/service/authenticateAccount.test.ts similarity index 92% rename from pkg/accounts/service/authenticate.test.ts rename to pkg/accounts/service/authenticateAccount.test.ts index a139e5d6..35ffa6f4 100644 --- a/pkg/accounts/service/authenticate.test.ts +++ b/pkg/accounts/service/authenticateAccount.test.ts @@ -5,7 +5,7 @@ import type { ID } from '../../id/type.js'; import { Argon2idPasswordEncoder } from '../../password/mod.js'; import { InMemoryAccountRepository } from '../adaptor/repository/dummy.js'; import { Account } from '../model/account.js'; -import { AuthenticationService } from './authenticate.js'; +import { AuthenticateAccountService } from './authenticateAccount.js'; import { TokenGenerator } from './tokenGenerator.js'; describe('AuthenticationService', () => { @@ -35,7 +35,7 @@ describe('AuthenticationService', () => { const tokenGenerator = await TokenGenerator.new(); - const service = new AuthenticationService({ + const service = new AuthenticateAccountService({ accountRepository: accountRepository, tokenGenerator: tokenGenerator, passwordEncoder: encoder, diff --git a/pkg/accounts/service/authenticate.ts b/pkg/accounts/service/authenticateAccount.ts similarity index 98% rename from pkg/accounts/service/authenticate.ts rename to pkg/accounts/service/authenticateAccount.ts index 254278d8..d9fb127b 100644 --- a/pkg/accounts/service/authenticate.ts +++ b/pkg/accounts/service/authenticateAccount.ts @@ -11,7 +11,7 @@ export interface TokenPair { refreshToken: string; } -export class AuthenticationService { +export class AuthenticateAccountService { private readonly accountRepository: AccountRepository; private readonly tokenGenerator: TokenGenerator; private readonly passwordEncoder: PasswordEncoder; diff --git a/pkg/accounts/service/follow.test.ts b/pkg/accounts/service/followAccount.test.ts similarity index 92% rename from pkg/accounts/service/follow.test.ts rename to pkg/accounts/service/followAccount.test.ts index 0b9898ba..783371be 100644 --- a/pkg/accounts/service/follow.test.ts +++ b/pkg/accounts/service/followAccount.test.ts @@ -7,7 +7,7 @@ import { InMemoryAccountRepository, } from '../adaptor/repository/dummy.js'; import { Account, type AccountID } from '../model/account.js'; -import { FollowService } from './follow.js'; +import { FollowAccountService } from './followAccount.js'; const accountRepository = new InMemoryAccountRepository(); await accountRepository.create( @@ -45,7 +45,7 @@ await accountRepository.create( }), ); const repository = new InMemoryAccountFollowRepository(); -const service = new FollowService(repository, accountRepository); +const service = new FollowAccountService(repository, accountRepository); describe('FollowService', () => { it('should follow', async () => { diff --git a/pkg/accounts/service/follow.ts b/pkg/accounts/service/followAccount.ts similarity index 92% rename from pkg/accounts/service/follow.ts rename to pkg/accounts/service/followAccount.ts index 9c650224..d4ad10e7 100644 --- a/pkg/accounts/service/follow.ts +++ b/pkg/accounts/service/followAccount.ts @@ -1,13 +1,13 @@ import { Option, Result } from '@mikuroxina/mini-fn'; import type { AccountName } from '../model/account.js'; -import { AccountFollow } from '../model/follow.js'; +import { AccountFollow } from '../model/followAccount.js'; import type { AccountFollowRepository, AccountRepository, } from '../model/repository.js'; -export class FollowService { +export class FollowAccountService { constructor( private readonly followRepository: AccountFollowRepository, private readonly accountRepository: AccountRepository, diff --git a/pkg/accounts/service/freeze.test.ts b/pkg/accounts/service/freezeAccount.test.ts similarity index 92% rename from pkg/accounts/service/freeze.test.ts rename to pkg/accounts/service/freezeAccount.test.ts index b9fe9b11..307e3b6e 100644 --- a/pkg/accounts/service/freeze.test.ts +++ b/pkg/accounts/service/freezeAccount.test.ts @@ -4,7 +4,7 @@ import { afterEach, describe, expect, it } from 'vitest'; import type { ID } from '../../id/type.js'; import { InMemoryAccountRepository } from '../adaptor/repository/dummy.js'; import { Account, type AccountID } from '../model/account.js'; -import { FreezeService } from './freeze.js'; +import { FreezeAccountService } from './freezeAccount.js'; const repository = new InMemoryAccountRepository(); await repository.create( @@ -22,7 +22,7 @@ await repository.create( createdAt: new Date(), }), ); -const freezeService = new FreezeService(repository); +const freezeService = new FreezeAccountService(repository); describe('FreezeService', () => { afterEach(() => repository.reset()); diff --git a/pkg/accounts/service/freeze.ts b/pkg/accounts/service/freezeAccount.ts similarity index 97% rename from pkg/accounts/service/freeze.ts rename to pkg/accounts/service/freezeAccount.ts index 06e30566..d3c196d5 100644 --- a/pkg/accounts/service/freeze.ts +++ b/pkg/accounts/service/freezeAccount.ts @@ -3,7 +3,7 @@ import { Option, Result } from '@mikuroxina/mini-fn'; import type { AccountName } from '../model/account.js'; import { type AccountRepository } from '../model/repository.js'; -export class FreezeService { +export class FreezeAccountService { private readonly accountRepository: AccountRepository; constructor(accountRepository: AccountRepository) { diff --git a/pkg/accounts/service/register.test.ts b/pkg/accounts/service/registerAccount.test.ts similarity index 90% rename from pkg/accounts/service/register.test.ts rename to pkg/accounts/service/registerAccount.test.ts index 0171846f..764fce48 100644 --- a/pkg/accounts/service/register.test.ts +++ b/pkg/accounts/service/registerAccount.test.ts @@ -8,9 +8,9 @@ import { InMemoryAccountVerifyTokenRepository, } from '../adaptor/repository/dummy.js'; import { type AccountName, type AccountRole } from '../model/account.js'; -import { TokenVerifyService } from './accountVerifyToken.js'; -import { RegisterAccountService } from './register.js'; +import { RegisterAccountService } from './registerAccount.js'; import { DummySendNotificationService } from './sendNotification.js'; +import { VerifyAccountTokenService } from './verifyAccountToken.js'; const repository = new InMemoryAccountRepository(); const verifyRepository = new InMemoryAccountVerifyTokenRepository(); @@ -21,7 +21,7 @@ const registerService: RegisterAccountService = new RegisterAccountService({ idGenerator: new SnowflakeIDGenerator(1, mockClock), passwordEncoder: new Argon2idPasswordEncoder(), sendNotification: new DummySendNotificationService(), - verifyTokenService: new TokenVerifyService( + verifyAccountTokenService: new VerifyAccountTokenService( verifyRepository, repository, mockClock, diff --git a/pkg/accounts/service/register.ts b/pkg/accounts/service/registerAccount.ts similarity index 89% rename from pkg/accounts/service/register.ts rename to pkg/accounts/service/registerAccount.ts index c7d1ae55..0ee14c26 100644 --- a/pkg/accounts/service/register.ts +++ b/pkg/accounts/service/registerAccount.ts @@ -9,8 +9,8 @@ import { type AccountRole, } from '../model/account.js'; import { type AccountRepository } from '../model/repository.js'; -import type { TokenVerifyService } from './accountVerifyToken.js'; import { type SendNotificationService } from './sendNotification.js'; +import type { VerifyAccountTokenService } from './verifyAccountToken.js'; export class AccountAlreadyExistsError extends Error { override readonly name = 'AccountAlreadyExistsError' as const; @@ -25,20 +25,20 @@ export class RegisterAccountService { private readonly snowflakeIDGenerator: SnowflakeIDGenerator; private readonly passwordEncoder: PasswordEncoder; private readonly sendNotificationService: SendNotificationService; - private readonly tokenVerifyService: TokenVerifyService; + private readonly verifyAccountTokenService: VerifyAccountTokenService; constructor(arg: { repository: AccountRepository; idGenerator: SnowflakeIDGenerator; passwordEncoder: PasswordEncoder; sendNotification: SendNotificationService; - verifyTokenService: TokenVerifyService; + verifyAccountTokenService: VerifyAccountTokenService; }) { this.accountRepository = arg.repository; this.snowflakeIDGenerator = arg.idGenerator; this.passwordEncoder = arg.passwordEncoder; this.sendNotificationService = arg.sendNotification; - this.tokenVerifyService = arg.verifyTokenService; + this.verifyAccountTokenService = arg.verifyAccountTokenService; } public async handle( @@ -81,7 +81,9 @@ export class RegisterAccountService { return Result.err(res[1]); } - const token = await this.tokenVerifyService.generate(account.getName()); + const token = await this.verifyAccountTokenService.generate( + account.getName(), + ); if (Result.isErr(token)) { return Result.err(token[1]); } diff --git a/pkg/accounts/service/resendToken.test.ts b/pkg/accounts/service/resendToken.test.ts index a4bd34c9..61601010 100644 --- a/pkg/accounts/service/resendToken.test.ts +++ b/pkg/accounts/service/resendToken.test.ts @@ -8,9 +8,9 @@ import { InMemoryAccountVerifyTokenRepository, } from '../adaptor/repository/dummy.js'; import { Account, type AccountID } from '../model/account.js'; -import { TokenVerifyService } from './accountVerifyToken.js'; import { ResendVerifyTokenService } from './resendToken.js'; import { DummySendNotificationService } from './sendNotification.js'; +import { VerifyAccountTokenService } from './verifyAccountToken.js'; const repository = new InMemoryAccountRepository(); await repository.create( @@ -49,7 +49,7 @@ await accountRepository.create( ); const mockClock = new MockClock(new Date('2023-09-10T00:00:00Z')); -const tokenVerifyService = new TokenVerifyService( +const verifyAccountTokenService = new VerifyAccountTokenService( verifyRepository, accountRepository, mockClock, @@ -62,7 +62,7 @@ describe('ResendVerifyTokenService', () => { it('resend verify token', async () => { const service = new ResendVerifyTokenService( repository, - tokenVerifyService, + verifyAccountTokenService, sendNotificationService, ); const actual = await service.handle('@john@example.com'); @@ -72,7 +72,7 @@ describe('ResendVerifyTokenService', () => { it('when account not found', async () => { const service = new ResendVerifyTokenService( repository, - tokenVerifyService, + verifyAccountTokenService, sendNotificationService, ); const actual = await service.handle('@a@example.com'); diff --git a/pkg/accounts/service/resendToken.ts b/pkg/accounts/service/resendToken.ts index ccd0ace4..109f63e3 100644 --- a/pkg/accounts/service/resendToken.ts +++ b/pkg/accounts/service/resendToken.ts @@ -2,21 +2,21 @@ import { Option, Result } from '@mikuroxina/mini-fn'; import type { AccountName } from '../model/account.js'; import { type AccountRepository } from '../model/repository.js'; -import type { TokenVerifyService } from './accountVerifyToken.js'; import { type SendNotificationService } from './sendNotification.js'; +import type { VerifyAccountTokenService } from './verifyAccountToken.js'; export class ResendVerifyTokenService { private readonly accountRepository: AccountRepository; - private readonly tokenVerifyService: TokenVerifyService; + private readonly verifyAccountTokenService: VerifyAccountTokenService; private readonly sendNotificationService: SendNotificationService; constructor( accountRepository: AccountRepository, - tokenVerifyService: TokenVerifyService, + verifyAccountTokenService: VerifyAccountTokenService, sendNotificationService: SendNotificationService, ) { this.accountRepository = accountRepository; - this.tokenVerifyService = tokenVerifyService; + this.verifyAccountTokenService = verifyAccountTokenService; this.sendNotificationService = sendNotificationService; } @@ -30,7 +30,9 @@ export class ResendVerifyTokenService { return Option.some(new Error('AccountAlreadyVerifiedError')); } - const token = await this.tokenVerifyService.generate(account[1].getName()); + const token = await this.verifyAccountTokenService.generate( + account[1].getName(), + ); if (Result.isErr(token)) { return Option.some(token[1]); } diff --git a/pkg/accounts/service/silence.test.ts b/pkg/accounts/service/silenceAccount.test.ts similarity index 92% rename from pkg/accounts/service/silence.test.ts rename to pkg/accounts/service/silenceAccount.test.ts index cdb43757..50df5c0e 100644 --- a/pkg/accounts/service/silence.test.ts +++ b/pkg/accounts/service/silenceAccount.test.ts @@ -4,7 +4,7 @@ import { afterEach, describe, expect, it } from 'vitest'; import type { ID } from '../../id/type.js'; import { InMemoryAccountRepository } from '../adaptor/repository/dummy.js'; import { Account, type AccountID } from '../model/account.js'; -import { SilenceService } from './silence.js'; +import { SilenceAccountService } from './silenceAccount.js'; const repository = new InMemoryAccountRepository(); await repository.create( @@ -22,7 +22,7 @@ await repository.create( createdAt: new Date(), }), ); -const silenceService = new SilenceService(repository); +const silenceService = new SilenceAccountService(repository); describe('SilenceService', () => { afterEach(() => repository.reset()); diff --git a/pkg/accounts/service/silence.ts b/pkg/accounts/service/silenceAccount.ts similarity index 96% rename from pkg/accounts/service/silence.ts rename to pkg/accounts/service/silenceAccount.ts index 1ad9ea6c..b5154007 100644 --- a/pkg/accounts/service/silence.ts +++ b/pkg/accounts/service/silenceAccount.ts @@ -3,7 +3,7 @@ import { Option, Result } from '@mikuroxina/mini-fn'; import { type AccountName } from '../model/account.js'; import { type AccountRepository } from '../model/repository.js'; -export class SilenceService { +export class SilenceAccountService { private readonly accountRepository: AccountRepository; constructor(accountRepository: AccountRepository) { diff --git a/pkg/accounts/service/unfollow.test.ts b/pkg/accounts/service/unfollowAccount.test.ts similarity index 88% rename from pkg/accounts/service/unfollow.test.ts rename to pkg/accounts/service/unfollowAccount.test.ts index 2509c489..cc2b3464 100644 --- a/pkg/accounts/service/unfollow.test.ts +++ b/pkg/accounts/service/unfollowAccount.test.ts @@ -7,8 +7,8 @@ import { InMemoryAccountRepository, } from '../adaptor/repository/dummy.js'; import { Account, type AccountID } from '../model/account.js'; -import { AccountFollow } from '../model/follow.js'; -import { UnfollowService } from './unfollow.js'; +import { AccountFollow } from '../model/followAccount.js'; +import { UnfollowAccountService } from './unfollowAccount.js'; const accountRepository = new InMemoryAccountRepository(); await accountRepository.create( @@ -52,7 +52,7 @@ const repository = new InMemoryAccountFollowRepository([ createdAt: new Date(), }), ]); -const service = new UnfollowService(repository, accountRepository); +const service = new UnfollowAccountService(repository, accountRepository); describe('UnfollowService', () => { it('should unfollow', async () => { diff --git a/pkg/accounts/service/unfollow.ts b/pkg/accounts/service/unfollowAccount.ts similarity index 96% rename from pkg/accounts/service/unfollow.ts rename to pkg/accounts/service/unfollowAccount.ts index a121aaba..609e8546 100644 --- a/pkg/accounts/service/unfollow.ts +++ b/pkg/accounts/service/unfollowAccount.ts @@ -6,7 +6,7 @@ import type { AccountRepository, } from '../model/repository.js'; -export class UnfollowService { +export class UnfollowAccountService { constructor( private readonly followRepository: AccountFollowRepository, private readonly accountRepository: AccountRepository, diff --git a/pkg/accounts/service/accountVerifyToken.test.ts b/pkg/accounts/service/verifyAccountToken.test.ts similarity index 92% rename from pkg/accounts/service/accountVerifyToken.test.ts rename to pkg/accounts/service/verifyAccountToken.test.ts index 9d33231c..d6a24d0c 100644 --- a/pkg/accounts/service/accountVerifyToken.test.ts +++ b/pkg/accounts/service/verifyAccountToken.test.ts @@ -8,7 +8,7 @@ import { InMemoryAccountVerifyTokenRepository, } from '../adaptor/repository/dummy.js'; import { Account, type AccountID } from '../model/account.js'; -import { TokenVerifyService } from './accountVerifyToken.js'; +import { VerifyAccountTokenService } from './verifyAccountToken.js'; const repository = new InMemoryAccountVerifyTokenRepository(); const accountRepository = new InMemoryAccountRepository(); @@ -31,7 +31,7 @@ await accountRepository.create( ); const mockClock = new MockClock(new Date('2023-09-10T00:00:00Z')); -const service = new TokenVerifyService( +const service = new VerifyAccountTokenService( repository, accountRepository, mockClock, @@ -54,7 +54,7 @@ describe('TokenVerifyService', () => { }); it('expired token', async () => { - const dummyService = new TokenVerifyService( + const dummyService = new VerifyAccountTokenService( repository, accountRepository, mockClock, diff --git a/pkg/accounts/service/accountVerifyToken.ts b/pkg/accounts/service/verifyAccountToken.ts similarity index 98% rename from pkg/accounts/service/accountVerifyToken.ts rename to pkg/accounts/service/verifyAccountToken.ts index 698a2df2..75a18286 100644 --- a/pkg/accounts/service/accountVerifyToken.ts +++ b/pkg/accounts/service/verifyAccountToken.ts @@ -7,7 +7,7 @@ import { type AccountVerifyTokenRepository, } from '../model/repository.js'; -export class TokenVerifyService { +export class VerifyAccountTokenService { constructor( private readonly repository: AccountVerifyTokenRepository, private readonly accountRepository: AccountRepository, diff --git a/pkg/notes/adaptor/controller/note.ts b/pkg/notes/adaptor/controller/note.ts index 4afbaac7..3d3da820 100644 --- a/pkg/notes/adaptor/controller/note.ts +++ b/pkg/notes/adaptor/controller/note.ts @@ -5,8 +5,8 @@ import type { AccountID } from '../../../accounts/model/account.js'; import type { ID } from '../../../id/type.js'; import type { AccountModule } from '../../../intermodule/account.js'; import type { NoteVisibility } from '../../model/note.js'; -import type { CreateNoteService } from '../../service/create.js'; -import type { FetchNoteService } from '../../service/fetch.js'; +import type { CreateNoteService } from '../../service/createNote.js'; +import type { FetchNoteService } from '../../service/fetchNote.js'; import { type CreateNoteResponseSchema, type GetNoteResponseSchema, diff --git a/pkg/notes/mod.ts b/pkg/notes/mod.ts index cf4da577..0097890d 100644 --- a/pkg/notes/mod.ts +++ b/pkg/notes/mod.ts @@ -7,27 +7,27 @@ import { InMemoryAccountRepository, InMemoryAccountVerifyTokenRepository, } from '../accounts/adaptor/repository/dummy.js'; -import { TokenVerifyService } from '../accounts/service/accountVerifyToken.js'; -import { AuthenticationService } from '../accounts/service/authenticate.js'; +import { AuthenticateAccountService } from '../accounts/service/authenticateAccount.js'; import { EditAccountService } from '../accounts/service/editAccount.js'; import { EtagVerifyService } from '../accounts/service/etagGenerateVerify.js'; import { FetchAccountService } from '../accounts/service/fetchAccount.js'; -import { FollowService } from '../accounts/service/follow.js'; -import { FreezeService } from '../accounts/service/freeze.js'; -import { RegisterAccountService } from '../accounts/service/register.js'; +import { FollowAccountService } from '../accounts/service/followAccount.js'; +import { FreezeAccountService } from '../accounts/service/freezeAccount.js'; +import { RegisterAccountService } from '../accounts/service/registerAccount.js'; import { ResendVerifyTokenService } from '../accounts/service/resendToken.js'; import { DummySendNotificationService } from '../accounts/service/sendNotification.js'; -import { SilenceService } from '../accounts/service/silence.js'; +import { SilenceAccountService } from '../accounts/service/silenceAccount.js'; import { TokenGenerator } from '../accounts/service/tokenGenerator.js'; -import { UnfollowService } from '../accounts/service/unfollow.js'; +import { UnfollowAccountService } from '../accounts/service/unfollowAccount.js'; +import { VerifyAccountTokenService } from '../accounts/service/verifyAccountToken.js'; import { SnowflakeIDGenerator } from '../id/mod.js'; import { AccountModule } from '../intermodule/account.js'; import { Argon2idPasswordEncoder } from '../password/mod.js'; import { NoteController } from './adaptor/controller/note.js'; import { InMemoryNoteRepository } from './adaptor/repository/dummy.js'; import { CreateNoteRoute, GetNoteRoute } from './router.js'; -import { CreateNoteService } from './service/create.js'; -import { FetchNoteService } from './service/fetch.js'; +import { CreateNoteService } from './service/createNote.js'; +import { FetchNoteService } from './service/fetchNote.js'; export const noteHandlers = new OpenAPIHono(); const noteRepository = new InMemoryNoteRepository(); @@ -47,7 +47,7 @@ class Clock { } const passwordEncoder = new Argon2idPasswordEncoder(); const accountController = new AccountController({ - authenticationService: new AuthenticationService({ + authenticateAccountService: new AuthenticateAccountService({ accountRepository: accountRepository, tokenGenerator: tokenGenerator, passwordEncoder: passwordEncoder, @@ -58,32 +58,35 @@ const accountController = new AccountController({ passwordEncoder, ), fetchAccountService: new FetchAccountService(accountRepository), - followService: new FollowService(accountFollowRepository, accountRepository), - freezeService: new FreezeService(accountRepository), + followAccountService: new FollowAccountService( + accountFollowRepository, + accountRepository, + ), + freezeAccountService: new FreezeAccountService(accountRepository), registerAccountService: new RegisterAccountService({ repository: accountRepository, idGenerator: idGenerator, passwordEncoder: passwordEncoder, sendNotification: new DummySendNotificationService(), - verifyTokenService: new TokenVerifyService( + verifyAccountTokenService: new VerifyAccountTokenService( accountVerifyTokenRepository, accountRepository, new Clock(), ), }), - silenceService: new SilenceService(accountRepository), - tokenVerifyService: new TokenVerifyService( + silenceAccountService: new SilenceAccountService(accountRepository), + verifyAccountTokenService: new VerifyAccountTokenService( accountVerifyTokenRepository, accountRepository, new Clock(), ), - unFollowService: new UnfollowService( + unfollowAccountService: new UnfollowAccountService( accountFollowRepository, accountRepository, ), resendTokenService: new ResendVerifyTokenService( accountRepository, - new TokenVerifyService( + new VerifyAccountTokenService( accountVerifyTokenRepository, accountRepository, new Clock(), diff --git a/pkg/notes/service/create.test.ts b/pkg/notes/service/createNote.test.ts similarity index 96% rename from pkg/notes/service/create.test.ts rename to pkg/notes/service/createNote.test.ts index 4fed9745..9227c17d 100644 --- a/pkg/notes/service/create.test.ts +++ b/pkg/notes/service/createNote.test.ts @@ -5,7 +5,7 @@ import type { AccountID } from '../../accounts/model/account.js'; import { SnowflakeIDGenerator } from '../../id/mod.js'; import type { ID } from '../../id/type.js'; import { InMemoryNoteRepository } from '../adaptor/repository/dummy.js'; -import { CreateNoteService } from './create.js'; +import { CreateNoteService } from './createNote.js'; const noteRepository = new InMemoryNoteRepository(); const createNoteService = new CreateNoteService( diff --git a/pkg/notes/service/create.ts b/pkg/notes/service/createNote.ts similarity index 100% rename from pkg/notes/service/create.ts rename to pkg/notes/service/createNote.ts diff --git a/pkg/notes/service/fetch.test.ts b/pkg/notes/service/fetchNote.test.ts similarity index 83% rename from pkg/notes/service/fetch.test.ts rename to pkg/notes/service/fetchNote.test.ts index 7e5eacdc..407932cc 100644 --- a/pkg/notes/service/fetch.test.ts +++ b/pkg/notes/service/fetchNote.test.ts @@ -8,26 +8,26 @@ import { InMemoryAccountVerifyTokenRepository, } from '../../accounts/adaptor/repository/dummy.js'; import { Account, type AccountID } from '../../accounts/model/account.js'; -import { TokenVerifyService } from '../../accounts/service/accountVerifyToken.js'; -import { AuthenticationService } from '../../accounts/service/authenticate.js'; +import { AuthenticateAccountService } from '../../accounts/service/authenticateAccount.js'; import { EditAccountService } from '../../accounts/service/editAccount.js'; import { EtagVerifyService } from '../../accounts/service/etagGenerateVerify.js'; import { FetchAccountService } from '../../accounts/service/fetchAccount.js'; -import { FollowService } from '../../accounts/service/follow.js'; -import { FreezeService } from '../../accounts/service/freeze.js'; -import { RegisterAccountService } from '../../accounts/service/register.js'; +import { FollowAccountService } from '../../accounts/service/followAccount.js'; +import { FreezeAccountService } from '../../accounts/service/freezeAccount.js'; +import { RegisterAccountService } from '../../accounts/service/registerAccount.js'; import { ResendVerifyTokenService } from '../../accounts/service/resendToken.js'; import { DummySendNotificationService } from '../../accounts/service/sendNotification.js'; -import { SilenceService } from '../../accounts/service/silence.js'; +import { SilenceAccountService } from '../../accounts/service/silenceAccount.js'; import { TokenGenerator } from '../../accounts/service/tokenGenerator.js'; -import { UnfollowService } from '../../accounts/service/unfollow.js'; +import { UnfollowAccountService } from '../../accounts/service/unfollowAccount.js'; +import { VerifyAccountTokenService } from '../../accounts/service/verifyAccountToken.js'; import { MockClock, SnowflakeIDGenerator } from '../../id/mod.js'; import type { ID } from '../../id/type.js'; import { AccountModule } from '../../intermodule/account.js'; import { Argon2idPasswordEncoder } from '../../password/mod.js'; import { InMemoryNoteRepository } from '../adaptor/repository/dummy.js'; import { Note, type NoteID } from '../model/note.js'; -import { FetchNoteService } from './fetch.js'; +import { FetchNoteService } from './fetchNote.js'; const testNote = Note.new({ id: '1' as ID, @@ -111,7 +111,7 @@ class Clock { const idGenerator = new SnowflakeIDGenerator(0, new MockClock(new Date())); const passwordEncoder = new Argon2idPasswordEncoder(); const accountController = new AccountController({ - authenticationService: new AuthenticationService({ + authenticateAccountService: new AuthenticateAccountService({ accountRepository: accountRepository, tokenGenerator: tokenGenerator, passwordEncoder: passwordEncoder, @@ -122,32 +122,35 @@ const accountController = new AccountController({ passwordEncoder, ), fetchAccountService: new FetchAccountService(accountRepository), - followService: new FollowService(accountFollowRepository, accountRepository), - freezeService: new FreezeService(accountRepository), + followAccountService: new FollowAccountService( + accountFollowRepository, + accountRepository, + ), + freezeAccountService: new FreezeAccountService(accountRepository), registerAccountService: new RegisterAccountService({ repository: accountRepository, idGenerator: idGenerator, passwordEncoder: passwordEncoder, sendNotification: new DummySendNotificationService(), - verifyTokenService: new TokenVerifyService( + verifyAccountTokenService: new VerifyAccountTokenService( accountVerifyTokenRepository, accountRepository, new Clock(), ), }), - silenceService: new SilenceService(accountRepository), - tokenVerifyService: new TokenVerifyService( + silenceAccountService: new SilenceAccountService(accountRepository), + verifyAccountTokenService: new VerifyAccountTokenService( accountVerifyTokenRepository, accountRepository, new Clock(), ), - unFollowService: new UnfollowService( + unfollowAccountService: new UnfollowAccountService( accountFollowRepository, accountRepository, ), resendTokenService: new ResendVerifyTokenService( accountRepository, - new TokenVerifyService( + new VerifyAccountTokenService( accountVerifyTokenRepository, accountRepository, new Clock(), diff --git a/pkg/notes/service/fetch.ts b/pkg/notes/service/fetchNote.ts similarity index 100% rename from pkg/notes/service/fetch.ts rename to pkg/notes/service/fetchNote.ts