Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions apps/meteor/app/apps/server/communication/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,38 @@ export class AppsRestApi {
},
);

this.api.addRoute(
'featured',
{ authRequired: true },
{
get() {
const baseUrl = orchestrator.getMarketplaceUrl();

const headers = getDefaultHeaders();
const token = getWorkspaceAccessToken();
if (token) {
headers.Authorization = `Bearer ${token}`;
}

let result;
try {
result = HTTP.get(`${baseUrl}/v1/apps/featured`, {
headers,
});
} catch (e) {
return handleError('Unable to access Marketplace. Does the server has access to the internet?', e);
}

if (!result || result.statusCode !== 200) {
orchestrator.getRocketChatLogger().error('Error getting the Featured Apps from the Marketplace:', result.data);
return API.v1.failure();
}

return API.v1.success(result.data);
},
},
);

this.api.addRoute(
':id',
{ authRequired: true, permissionsRequired: ['manage-apps'] },
Expand Down
11 changes: 11 additions & 0 deletions packages/core-typings/src/FeaturedApps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { App } from './Apps';

export type FeaturedAppsSections = {
sections: FeaturedAppsSection[];
};

export type FeaturedAppsSection = {
i18nLabel: string;
slug: string;
apps: App[];
};
1 change: 1 addition & 0 deletions packages/core-typings/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './Apps';
export * from './FeaturedApps';
export * from './IRoom';
export * from './UIKit';
export * from './IMessage';
Expand Down
8 changes: 7 additions & 1 deletion packages/rest-typings/src/apps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { IExternalComponent } from '@rocket.chat/apps-engine/definition/ext
import type { IPermission } from '@rocket.chat/apps-engine/definition/permissions/IPermission';
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
import type { IUIActionButton } from '@rocket.chat/apps-engine/definition/ui';
import type { AppScreenshot, App } from '@rocket.chat/core-typings';
import type { AppScreenshot, App, FeaturedAppsSections } from '@rocket.chat/core-typings';

export type AppsEndpoints = {
'/apps/externalComponents': {
Expand Down Expand Up @@ -96,6 +96,12 @@ export type AppsEndpoints = {
};
};

'/apps/featured': {
GET: () => {
sections: FeaturedAppsSections;
};
};

'/apps': {
GET:
| ((params: { buildExternalUrl: 'true'; purchaseType?: 'buy' | 'subscription'; appId?: string; details?: 'true' | 'false' }) => {
Expand Down