[PR #3175] [MERGED] HBE-152 refactor: team invitation module in pseudo fp-ts #4266

Closed
opened 2026-03-17 01:49:11 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/3175
Author: @mirarifhasan
Created: 7/7/2023
Status: Merged
Merged: 7/13/2023
Merged by: @AndrewBastin

Base: release/2023.4.8Head: refactor/team-invitation


📝 Commits (5)

  • 54bef30 refactor: team invitation module
  • b58acfe feat: added all feedback
  • e0cc143 chore: input-arg file added
  • 1d93745 chore: improved code readability
  • 089f682 chore: removed stated return type

📊 Changes

10 files changed (+291 additions, -444 deletions)

View changed files

📝 packages/hoppscotch-backend/src/admin/admin.service.ts (+2 -2)
📝 packages/hoppscotch-backend/src/auth/auth.service.ts (+1 -1)
📝 packages/hoppscotch-backend/src/mailer/mailer.service.ts (+3 -23)
packages/hoppscotch-backend/src/team-invitation/input-type.args.ts (+20 -0)
📝 packages/hoppscotch-backend/src/team-invitation/team-invitation.resolver.ts (+37 -81)
📝 packages/hoppscotch-backend/src/team-invitation/team-invitation.service.ts (+159 -213)
📝 packages/hoppscotch-backend/src/team-invitation/team-invite-team-owner.guard.ts (+23 -41)
📝 packages/hoppscotch-backend/src/team-invitation/team-invite-viewer.guard.ts (+29 -44)
📝 packages/hoppscotch-backend/src/team-invitation/team-invitee.guard.ts (+16 -38)
📝 packages/hoppscotch-backend/src/team-invitation/team-teaminvite-ext.resolver.ts (+1 -1)

📄 Description

Closes HBE-152

Description

This PR introduces code refactoring that improves the consistency of coding patterns for team invitation module across the other modules. Previously team invitation module was written in fp-ts way, and now it's being converted into pseudo fp-ts way.

Showing a general difference between fp-ts and pseudo fp-ts:

  getInvitation(inviteID: string): TO.TaskOption<TeamInvitation> {
    return pipe(
      () =>
        this.prisma.teamInvitation.findUnique({
          where: {
            id: inviteID,
          },
        }),
      TO.fromTask,
      TO.chain(flow(O.fromNullable, TO.fromOption)),
      TO.map((x) => x as TeamInvitation),
    );
  }
  async getInvitation(
    inviteID: string,
  ): Promise<O.None | O.Some<TeamInvitation>> {
    try {
      const dbInvitation = await this.prisma.teamInvitation.findUniqueOrThrow({
        where: {
          id: inviteID,
        },
      });

      return O.some(this.castToTeamInvitation(dbInvitation));
    } catch (e) {
      return O.none;
    }
  }

Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

Additional Information


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/3175 **Author:** [@mirarifhasan](https://github.com/mirarifhasan) **Created:** 7/7/2023 **Status:** ✅ Merged **Merged:** 7/13/2023 **Merged by:** [@AndrewBastin](https://github.com/AndrewBastin) **Base:** `release/2023.4.8` ← **Head:** `refactor/team-invitation` --- ### 📝 Commits (5) - [`54bef30`](https://github.com/hoppscotch/hoppscotch/commit/54bef30cf89a96ef7e8d63b356d4550890046b73) refactor: team invitation module - [`b58acfe`](https://github.com/hoppscotch/hoppscotch/commit/b58acfe8dc20d23b883f7c03d392da612cf7ab5f) feat: added all feedback - [`e0cc143`](https://github.com/hoppscotch/hoppscotch/commit/e0cc143436aa1db6418222eef3be13351519ebcc) chore: input-arg file added - [`1d93745`](https://github.com/hoppscotch/hoppscotch/commit/1d93745a4ee9cb4eb7387f6b94def0e02802816b) chore: improved code readability - [`089f682`](https://github.com/hoppscotch/hoppscotch/commit/089f6823e6cb368d938751db83b708f460a99521) chore: removed stated return type ### 📊 Changes **10 files changed** (+291 additions, -444 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-backend/src/admin/admin.service.ts` (+2 -2) 📝 `packages/hoppscotch-backend/src/auth/auth.service.ts` (+1 -1) 📝 `packages/hoppscotch-backend/src/mailer/mailer.service.ts` (+3 -23) ➕ `packages/hoppscotch-backend/src/team-invitation/input-type.args.ts` (+20 -0) 📝 `packages/hoppscotch-backend/src/team-invitation/team-invitation.resolver.ts` (+37 -81) 📝 `packages/hoppscotch-backend/src/team-invitation/team-invitation.service.ts` (+159 -213) 📝 `packages/hoppscotch-backend/src/team-invitation/team-invite-team-owner.guard.ts` (+23 -41) 📝 `packages/hoppscotch-backend/src/team-invitation/team-invite-viewer.guard.ts` (+29 -44) 📝 `packages/hoppscotch-backend/src/team-invitation/team-invitee.guard.ts` (+16 -38) 📝 `packages/hoppscotch-backend/src/team-invitation/team-teaminvite-ext.resolver.ts` (+1 -1) </details> ### 📄 Description <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> <!-- Issue # here --> Closes HBE-152 ### Description <!-- Add a brief description of the pull request --> This PR introduces code refactoring that improves the consistency of coding patterns for `team invitation` module across the other modules. Previously `team invitation` module was written in fp-ts way, and now it's being converted into pseudo fp-ts way. Showing a general difference between fp-ts and pseudo fp-ts: ```ts getInvitation(inviteID: string): TO.TaskOption<TeamInvitation> { return pipe( () => this.prisma.teamInvitation.findUnique({ where: { id: inviteID, }, }), TO.fromTask, TO.chain(flow(O.fromNullable, TO.fromOption)), TO.map((x) => x as TeamInvitation), ); } ``` ```ts async getInvitation( inviteID: string, ): Promise<O.None | O.Some<TeamInvitation>> { try { const dbInvitation = await this.prisma.teamInvitation.findUniqueOrThrow({ where: { id: inviteID, }, }); return O.some(this.castToTeamInvitation(dbInvitation)); } catch (e) { return O.none; } } ``` <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Checks <!-- Make sure your pull request passes the CI checks and do check the following fields as needed - --> - [x] My pull request adheres to the code style of this project - [ ] My code requires changes to the documentation - [ ] I have updated the documentation as required - [x] All the tests have passed ### Additional Information <!-- Any additional information like breaking changes, dependencies added, screenshots, comparisons between new and old behaviour, etc. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 01:49:11 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#4266
No description provided.