Skip to content

Commit

Permalink
Remove tenants from api endpoints (#2765)
Browse files Browse the repository at this point in the history
  • Loading branch information
epipav authored Jan 20, 2025
1 parent bb79476 commit 4bab0c1
Show file tree
Hide file tree
Showing 150 changed files with 5,394 additions and 5,619 deletions.
6 changes: 1 addition & 5 deletions backend/src/api/activity/activityAddWithMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* POST /tenant/{tenantId}/activity/with-member
* POST /activity/with-member
* @summary Create or update an activity with a member
* @tag Activities
* @security Bearer
* @description Create or update an activity with a member
* Activity existence is checked by sourceId and tenantId
* Member existence is checked by platform and username
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {ActivityUpsertWithMemberInput} application/json
* @response 200 - Ok
* @responseContent {Activity} 200.application/json
Expand All @@ -20,10 +19,7 @@ import PermissionChecker from '../../services/user/permissionChecker'
* @response 429 - Too many requests
*/
export default async (req, res) => {
// Check we have the Create permissions
new PermissionChecker(req).validateHas(Permissions.values.activityCreate)
// Call the createWithMember function in activity service
// to create the activity.
const payload = await new ActivityService(req).createWithMember(req.body)

await req.responseHandler.success(req, res, payload)
Expand Down
5 changes: 2 additions & 3 deletions backend/src/api/activity/activityChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* GET /tenant/{tenantId}/activity/channel
* GET /activity/channel
* @summary List activity channels
* @tag Activities
* @security Bearer
* @description Find all activity channels of a given tenant
* @pathParam {string} tenantId - Your workspace/tenant ID
* @description Find all activity channels
* @response 200 - Ok
* @responseContent {ActivityResponse} 200.application/json
* @responseExample {ActivityFind} 200.application/json.Activity
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/activity/activityCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* POST /tenant/{tenantId}/activity
* POST /activity
* @summary Create or update an activity
* @tag Activities
* @security Bearer
* @description Create or update an activity. Existence is checked by sourceId and tenantId
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {ActivityUpsertInput} application/json
* @response 200 - Ok
* @responseContent {Activity} 200.application/json
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/activity/activityDestroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* DELETE /tenant/{tenantId}/activity/{id}
* DELETE /activity/{id}
* @summary Delete an activity
* @tag Activities
* @security Bearer
* @description Delete a activity given an ID
* @pathParam {string} tenantId - Your workspace/tenant ID
* @pathParam {string} id - The ID of the activity
* @response 200 - Ok
* @response 401 - Unauthorized
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/activity/activityFind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* GET /tenant/{tenantId}/activity/{id}
* GET /activity/{id}
* @summary Find an activity
* @tag Activities
* @security Bearer
Expand Down
13 changes: 0 additions & 13 deletions backend/src/api/activity/activityImport.ts

This file was deleted.

3 changes: 1 addition & 2 deletions backend/src/api/activity/activityQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* POST /tenant/{tenantId}/activity/query
* POST /activity/query
* @summary Query activities
* @tag Activities
* @security Bearer
* @description Query activities. It accepts filters, sorting options and pagination.
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {ActivityQuery} application/json
* @response 200 - Ok
* @responseContent {ActivityList} 200.application/json
Expand Down
15 changes: 0 additions & 15 deletions backend/src/api/activity/activityTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@ import Permissions from '../../security/permissions'
import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* GET /tenant/{tenantId}/activity/{id}
* @summary Find an activity
* @tag Activities
* @security Bearer
* @description Find a single activity by ID
* @pathParam {string} tenantId - Your workspace/tenant ID
* @pathParam {string} id - The ID of the activity
* @response 200 - Ok
* @responseContent {ActivityResponse} 200.application/json
* @responseExample {ActivityFind} 200.application/json.Activity
* @response 401 - Unauthorized
* @response 404 - Not found
* @response 429 - Too many requests
*/
export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.activityRead)
const payload = await new ActivityService(req).findActivityTypes(req.query.segments)
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/activity/activityUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* PUT /tenant/{tenantId}/activity/{id}
* PUT /activity/{id}
* @summary Update an activity
* @tag Activities
* @security Bearer
* @description Update an activity given an ID.
* @pathParam {string} tenantId - Your workspace/tenant ID
* @pathParam {string} id - The ID of the activity
* @bodyContent {ActivityUpsertInput} application/json
* @response 200 - Ok
Expand Down
20 changes: 7 additions & 13 deletions backend/src/api/activity/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { safeWrap } from '../../middlewares/errorMiddleware'

export default (app) => {
app.post(`/tenant/:tenantId/activity`, safeWrap(require('./activityCreate').default))
app.post(`/tenant/:tenantId/activity/query`, safeWrap(require('./activityQuery').default))
app.put(`/tenant/:tenantId/activity/:id`, safeWrap(require('./activityUpdate').default))
app.post(`/tenant/:tenantId/activity/import`, safeWrap(require('./activityImport').default))
app.delete(`/tenant/:tenantId/activity`, safeWrap(require('./activityDestroy').default))
app.get(`/tenant/:tenantId/activity/type`, safeWrap(require('./activityTypes').default))
app.get(`/tenant/:tenantId/activity/channel`, safeWrap(require('./activityChannels').default))
// app.get(`/tenant/:tenantId/activity/:id`, safeWrap(require('./activityFind').default))
app.post(
'/tenant/:tenantId/activity/with-member',
// Call the addActivityWithMember file in this dir
safeWrap(require('./activityAddWithMember').default),
)
app.post(`/activity`, safeWrap(require('./activityCreate').default))
app.post(`/activity/query`, safeWrap(require('./activityQuery').default))
app.put(`/activity/:id`, safeWrap(require('./activityUpdate').default))
app.delete(`/activity`, safeWrap(require('./activityDestroy').default))
app.get(`/activity/type`, safeWrap(require('./activityTypes').default))
app.get(`/activity/channel`, safeWrap(require('./activityChannels').default))
app.post('/activity/with-member', safeWrap(require('./activityAddWithMember').default))
}
4 changes: 2 additions & 2 deletions backend/src/api/auditLog/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { safeWrap } from '../../middlewares/errorMiddleware'

export default (app) => {
app.get(`/tenant/:tenantId/audit-log`, safeWrap(require('./auditLogList').default))
app.get(`/audit-log`, safeWrap(require('./auditLogList').default))

app.post(`/tenant/:tenantId/audit-logs/query`, safeWrap(require('./auditLogsQuery').default))
app.post(`/audit-logs/query`, safeWrap(require('./auditLogsQuery').default))
}
4 changes: 3 additions & 1 deletion backend/src/api/auth/authSignIn.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { getDefaultTenantId } from '@crowd/common'

import AuthService from '../../services/auth/authService'

export default async (req, res) => {
const payload = await AuthService.signin(
req.body.email,
req.body.password,
req.body.invitationToken,
req.body.tenantId,
getDefaultTenantId(),
req,
)

Expand Down
4 changes: 3 additions & 1 deletion backend/src/api/auth/authSignUp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getDefaultTenantId } from '@crowd/common'

import AuthService from '../../services/auth/authService'

export default async (req, res) => {
Expand All @@ -8,7 +10,7 @@ export default async (req, res) => {
req.body.email,
req.body.password,
req.body.invitationToken,
req.body.tenantId,
getDefaultTenantId(),
req.body.firstName,
req.body.lastName,
req.body.acceptedTermsAndPrivacy,
Expand Down
3 changes: 2 additions & 1 deletion backend/src/api/auth/authSocial.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import passport from 'passport'

import { getDefaultTenantId } from '@crowd/common'
import { getServiceChildLogger } from '@crowd/logging'

import { API_CONFIG, GITHUB_CONFIG, GOOGLE_CONFIG } from '../../conf'
Expand All @@ -21,7 +22,7 @@ export default (app, routes) => {
routes.post('/auth/social/onboard', async (req, res) => {
const payload = await AuthService.handleOnboard(
req.currentUser,
{ invitationToken: req.body.invitationToken, tenantId: req.body.tenantId },
{ invitationToken: req.body.invitationToken, tenantId: getDefaultTenantId() },
req,
)

Expand Down
5 changes: 3 additions & 2 deletions backend/src/api/auth/ssoCallback.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import jwt from 'jsonwebtoken'
import jwksClient from 'jwks-rsa'

import { Error401 } from '@crowd/common'
import { Error401, getDefaultTenantId } from '@crowd/common'

import { AUTH0_CONFIG } from '../../conf'
import AuthService from '../../services/auth/authService'
Expand All @@ -21,7 +21,8 @@ async function getKey(header, callback) {
}

export default async (req, res) => {
const { idToken, invitationToken, tenantId } = req.body
const { idToken, invitationToken } = req.body
const tenantId = getDefaultTenantId()

try {
const verifyToken = new Promise((resolve, reject) => {
Expand Down
31 changes: 0 additions & 31 deletions backend/src/api/automation/automationCreate.ts

This file was deleted.

27 changes: 0 additions & 27 deletions backend/src/api/automation/automationDestroy.ts

This file was deleted.

40 changes: 0 additions & 40 deletions backend/src/api/automation/automationExecutionFind.ts

This file was deleted.

24 changes: 0 additions & 24 deletions backend/src/api/automation/automationFind.ts

This file was deleted.

Loading

0 comments on commit 4bab0c1

Please sign in to comment.