File tree 6 files changed +62
-7
lines changed
prisma/migrations/20240513235110_add_default_value_in_update_at_account 6 files changed +62
-7
lines changed Original file line number Diff line number Diff line change 1
1
import js from '@eslint/js' ;
2
2
import eslintConfigPrettier from 'eslint-config-prettier' ;
3
3
import { defineFlatConfig } from 'eslint-define-config' ;
4
- import tsEslint from 'typescript-eslint' ;
5
4
import importPlugin from 'eslint-plugin-import' ;
6
5
import perfectionist from 'eslint-plugin-perfectionist' ;
7
6
import unicornPlugin from 'eslint-plugin-unicorn' ;
8
7
import vitestPlugin from 'eslint-plugin-vitest' ;
9
8
import globals from 'globals' ;
9
+ import tsEslint from 'typescript-eslint' ;
10
10
11
11
import 'eslint-plugin-only-warn' ;
12
12
@@ -56,7 +56,7 @@ export default defineFlatConfig([
56
56
'import/no-named-as-default' : 'warn' ,
57
57
'import/no-named-as-default-member' : 'warn' ,
58
58
'import/no-unused-modules' : 'warn' ,
59
- 'import/order' : 'warn ' ,
59
+ 'import/order' : 'off ' ,
60
60
61
61
'perfectionist/sort-array-includes' : 'warn' ,
62
62
'perfectionist/sort-classes' : 'warn' ,
Original file line number Diff line number Diff line change
1
+ -- AlterTable
2
+ ALTER TABLE " accounts" ALTER COLUMN " updated_at" SET DEFAULT CURRENT_TIMESTAMP ;
Original file line number Diff line number Diff line change 1
1
import type { RequestHandler } from 'express' ;
2
2
import type { UserCreateModel } from '../models/user-create-model.js' ;
3
- import { userCreateSchema , userFindByIdSchema } from '../validators/index.js' ;
4
3
import type { UserFindByIdModel } from '../models/user-find-by-id-model.js' ;
4
+ import { userCreateSchema , userFindByIdSchema } from '../validators/index.js' ;
5
5
import { userIdParamsSchema } from '../validators/user-id-schema.js' ;
6
- import type { Controller } from '@/shared/protocols/controller.js' ;
7
- import type { Service } from '@/shared/protocols/service.js' ;
6
+
8
7
import type { Validator } from '@/shared/infra/validator/validator.js' ;
8
+ import type { Controller } from '@/shared/protocols/controller.js' ;
9
9
import type { AsyncRequestHandler } from '@/shared/protocols/handlers.js' ;
10
10
import { HttpStatusCode } from '@/shared/protocols/http-client.js' ;
11
+ import type { Service } from '@/shared/protocols/service.js' ;
11
12
12
13
export class UserController implements Controller {
13
14
create : AsyncRequestHandler = async ( req , res , next ) => {
Original file line number Diff line number Diff line change
1
+ import { AccountRepository } from './account-repository.js' ;
2
+ import { AccountMock } from '@/shared/test-helpers/mocks/account.mock.js' ;
3
+ import { prisma } from 'mocks/prisma.js' ;
4
+
5
+ const makeSut = ( ) => {
6
+ const repository = new AccountRepository ( ) ;
7
+
8
+ return { repository } ;
9
+ } ;
10
+
11
+ describe ( '[Repositories] AccountRepository' , ( ) => {
12
+ it ( 'should call service for create account' , async ( ) => {
13
+ const { repository } = makeSut ( ) ;
14
+
15
+ const account = AccountMock . create ( ) ;
16
+
17
+ await repository . create ( account ) ;
18
+
19
+ const { id, ...accountWithoutId } = account ;
20
+
21
+ expect ( prisma . account . create ) . toHaveBeenCalledWith ( {
22
+ data : accountWithoutId ,
23
+ } ) ;
24
+ } ) ;
25
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import type { Prisma } from '@prisma/client' ;
2
+ import { database } from '@/shared/infra/database/database.js' ;
3
+
4
+ type CreateAccountParams = Prisma . Args <
5
+ typeof database . account ,
6
+ 'create'
7
+ > [ 'data' ] ;
8
+ export class AccountRepository {
9
+ async create ( { avatarUrl, socialMediaId, userId } : CreateAccountParams ) {
10
+ return await database . account . create ( {
11
+ data : {
12
+ avatarUrl,
13
+ socialMediaId,
14
+ userId,
15
+ } ,
16
+ } ) ;
17
+ }
18
+
19
+ async findAccountsByUserId ( id : string ) {
20
+ const socialMidias = await database . account . findMany ( {
21
+ where : {
22
+ userId : id ,
23
+ } ,
24
+ } ) ;
25
+ return socialMidias ;
26
+ }
27
+ }
Original file line number Diff line number Diff line change 1
- import type { Prisma } from '@prisma/client' ;
2
- import { database } from '@/shared/infra/database/database.js' ;
3
1
import { prismaErrorHandler } from '@/shared/errors/prisma-error.js' ;
2
+ import { database } from '@/shared/infra/database/database.js' ;
3
+ import type { Prisma } from '@prisma/client' ;
4
4
5
5
type CreateUserParams = Prisma . Args < typeof database . user , 'create' > [ 'data' ] ;
6
6
You can’t perform that action at this time.
0 commit comments