-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import User from '@domain/entities/user.js'; | ||
|
||
export type UserList = { | ||
users: User[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type User from '@domain/entities/user'; | ||
import type UserListRepository from '@repository/userList.repository'; | ||
|
||
|
||
export default class UserListService { | ||
public readonly repository: UserListRepository; | ||
|
||
constructor(repository: UserListRepository) { | ||
this.repository = repository; | ||
} | ||
|
||
public async getAllUsersById(): Promise<User[]> { | ||
return await this.repository.getAllUsersById(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
import type { FastifyPluginCallback } from 'fastify'; | ||
import userListService from '@domain/service/userListService'; | ||
import { request } from 'http'; | ||
|
||
interface UsersRouterOptions { | ||
|
||
userListService: userListService, | ||
} | ||
|
||
|
||
const AllUsersRouter: FastifyPluginCallback<UsersRouterOptions> = (fastify, opts, done) => { | ||
|
||
const usersService = opts.userListService; | ||
fastify.get('/allUsers', { | ||
|
||
}, async (request, reply) => { | ||
// const { userId } = request; | ||
const userList = await usersService.getAllUsersById(); | ||
if (userList != null) { | ||
return reply.send(userList); | ||
} else { | ||
return reply.send({message: '!'}) | ||
} | ||
}); | ||
|
||
done(); | ||
}; | ||
export default AllUsersRouter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import User from '@domain/entities/user'; | ||
// import type User from '@domain/entities/user'; | ||
import type UserStorage from '@repository/storage/user.storage.js'; | ||
|
||
|
||
export default class UserListRepository { | ||
|
||
public storage: UserStorage; | ||
|
||
constructor(storage: UserStorage) { | ||
this.storage = storage; | ||
} | ||
|
||
|
||
|
||
public async getAllUsersById(): Promise<User[]> { | ||
return await this.storage.getAllUsersById(); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |