-
Notifications
You must be signed in to change notification settings - Fork 0
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
arturvoloshyn
committed
Mar 20, 2024
1 parent
9de59dc
commit c74ff1d
Showing
55 changed files
with
477 additions
and
670 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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,13 @@ | ||
import { coursesListController } from "@/features/courses-list/controller"; | ||
import { createContext, sharedRouter, t } from "@/kernel/lib/trpc/server"; | ||
import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; | ||
|
||
const handler = (req: Request) => | ||
fetchRequestHandler({ | ||
endpoint: "/api/trpc", | ||
req, | ||
router: t.mergeRouters(sharedRouter, coursesListController), | ||
createContext: createContext, | ||
}); | ||
|
||
export { handler as GET, handler as POST }; |
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 |
---|---|---|
@@ -1 +1 @@ | ||
export { getCoursesListUseCase } from "./_use-cases/get-courses-list"; | ||
export { getCoursesListService } from "./_services/get-courses-list"; |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { ROLES, SessionEntity, UserId } from "./types"; | ||
import { SharedSession, UserId, ROLES } from "@/kernel/domain/user"; | ||
|
||
export const createUserAbility = (session: SessionEntity) => ({ | ||
export const createUserAbility = (session: SharedSession) => ({ | ||
canGetUser: (userId: UserId) => | ||
session.user.id === userId || session.user.role === ROLES.ADMIN, | ||
}); | ||
|
||
export const createProfileAbility = (session: SessionEntity) => ({ | ||
export const createProfileAbility = (session: SharedSession) => ({ | ||
canUpdateProfile: (userId: UserId) => | ||
session.user.id === userId || session.user.role === ROLES.ADMIN, | ||
}); |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,14 @@ | ||
import { UserId, SharedUser } from "@/kernel/domain/user"; | ||
import { dbClient } from "@/shared/lib/db"; | ||
import { UserEntity, UserId } from "../_domain/types"; | ||
|
||
export class UserRepository { | ||
async getUserById(userId: UserId): Promise<UserEntity> { | ||
async getUserById(userId: UserId): Promise<SharedUser> { | ||
return dbClient.user.findUniqueOrThrow({ | ||
where: { | ||
id: userId, | ||
}, | ||
}); | ||
} | ||
|
||
async createUser(user: UserEntity): Promise<UserEntity> { | ||
return await dbClient.user.create({ | ||
data: user, | ||
}); | ||
} | ||
} | ||
|
||
export const userRepository = new UserRepository(); |
Oops, something went wrong.