Skip to content

Commit

Permalink
Review change name feat to features
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoncool committed Nov 22, 2024
1 parent e7ca14f commit d44bb9a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ const extendedRoutes = getRoutes(nodekit, {beforeAuth, afterAuth});

const routes: AppRoutes = {};
objectKeys(extendedRoutes).forEach((key) => {
const {route, feat, ...params} = extendedRoutes[key];
if (!Array.isArray(feat) || feat.every((flag) => isEnabledFeature(nodekit.ctx, flag))) {
const {route, features, ...params} = extendedRoutes[key];
if (
!Array.isArray(features) ||
features.every((feature) => isEnabledFeature(nodekit.ctx, feature))
) {
routes[route] = params;
}
});
Expand Down
76 changes: 38 additions & 38 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type GetRoutesOptions = {

export type ExtendedAppRouteDescription<F = Feature> = AppRouteDescription & {
route: `${Uppercase<HttpMethod>} ${string}`;
feat?: F[];
features?: F[];
};

// eslint-disable-next-line complexity
Expand Down Expand Up @@ -270,95 +270,95 @@ export function getRoutes(_nodekit: NodeKit, options: GetRoutesOptions) {
getWorkbookContent: makeRoute({
route: 'GET /v2/workbooks/:workbookId/entries',
handler: workbooksController.getContent,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
privateGetWorkbookContent: makeRoute({
route: 'GET /private/v2/workbooks/:workbookId/entries',
handler: workbooksController.getContent,
authPolicy: AuthPolicy.disabled,
private: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
getWorkbook: makeRoute({
route: 'GET /v2/workbooks/:workbookId',
handler: workbooksController.get,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
privateGetWorkbook: makeRoute({
route: 'GET /private/v2/workbooks/:workbookId',
handler: workbooksController.get,
authPolicy: AuthPolicy.disabled,
private: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
getWorkbooks: makeRoute({
route: 'GET /v2/workbooks',
handler: workbooksController.getList,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
updateWorkbook: makeRoute({
route: 'POST /v2/workbooks/:workbookId/update',
handler: workbooksController.update,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
createWorkbook: makeRoute({
route: 'POST /v2/workbooks',
handler: workbooksController.create,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
privateCreateWorkbook: makeRoute({
route: 'POST /private/v2/workbooks',
handler: workbooksController.create,
write: true,
authPolicy: AuthPolicy.disabled,
private: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
deleteWorkbook: makeRoute({
route: 'DELETE /v2/workbooks/:workbookId',
handler: workbooksController.delete,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
deleteWorkbooks: makeRoute({
route: 'DELETE /v2/delete-workbooks',
handler: workbooksController.deleteList,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
moveWorkbook: makeRoute({
route: 'POST /v2/workbooks/:workbookId/move',
handler: workbooksController.move,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
moveWorkbooks: makeRoute({
route: 'POST /v2/move-workbooks',
handler: workbooksController.moveList,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
copyWorkbook: makeRoute({
route: 'POST /v2/workbooks/:workbookId/copy',
handler: workbooksController.copy,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
copyWorkbookTemplate: makeRoute({
route: 'POST /v2/workbooks/:workbookId/copyTemplate',
handler: workbooksController.copyTemplate,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
privateSetIsTemplateWorkbook: makeRoute({
route: 'POST /private/v2/workbooks/:workbookId/setIsTemplate',
handler: workbooksController.setIsTemplate,
authPolicy: AuthPolicy.disabled,
private: true,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),

privateRestoreWorkbook: makeRoute({
Expand All @@ -367,136 +367,136 @@ export function getRoutes(_nodekit: NodeKit, options: GetRoutesOptions) {
authPolicy: AuthPolicy.disabled,
private: true,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),

privateGetAllWorkbooks: makeRoute({
route: 'GET /private/all-workbooks',
handler: workbooksController.getAll,
authPolicy: AuthPolicy.disabled,
private: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),

createCollection: makeRoute({
route: 'POST /v1/collections',
handler: collectionsController.create,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
privateCreateCollection: makeRoute({
route: 'POST /private/v1/collections',
handler: collectionsController.create,
write: true,
authPolicy: AuthPolicy.disabled,
private: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
getCollection: makeRoute({
route: 'GET /v1/collections/:collectionId',
handler: collectionsController.get,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
privateGetCollection: makeRoute({
route: 'GET /private/v1/collections/:collectionId',
handler: collectionsController.get,
authPolicy: AuthPolicy.disabled,
private: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
getCollectionContent: makeRoute({
route: 'GET /v1/collection-content',
handler: collectionsController.getContent,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
getStructureItems: makeRoute({
route: 'GET /v1/structure-items',
handler: structureItemsController.getStructureItems,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
getRootCollectionPermissions: makeRoute({
route: 'GET /v1/root-collection-permissions',
handler: collectionsController.getRootPermissions,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
getCollectionBreadcrumbs: makeRoute({
route: 'GET /v1/collections/:collectionId/breadcrumbs',
handler: collectionsController.getBreadcrumbs,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
deleteCollection: makeRoute({
route: 'DELETE /v1/collections/:collectionId',
handler: collectionsController.delete,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
deleteCollections: makeRoute({
route: 'DELETE /v1/delete-collections',
handler: collectionsController.deleteList,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
moveCollection: makeRoute({
route: 'POST /v1/collections/:collectionId/move',
handler: collectionsController.move,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
moveCollections: makeRoute({
route: 'POST /v1/move-collections',
handler: collectionsController.moveList,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),
updateCollection: makeRoute({
route: 'POST /v1/collections/:collectionId/update',
handler: collectionsController.update,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),

copyEntryToWorkbook: makeRoute({
route: 'POST /v2/entries/:entryId/copy',
handler: entriesController.copyEntryToWorkbook,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),

copyEntriesToWorkbook: makeRoute({
route: 'POST /v2/copy-entries',
handler: entriesController.copyEntriesToWorkbook,
write: true,
feat: [Feature.CollectionsEnabled],
features: [Feature.CollectionsEnabled],
}),

getColorPalettes: makeRoute({
route: 'GET /v1/color-palettes',
handler: colorPalettesController.getList,
feat: [Feature.ColorPalettesEnabled],
features: [Feature.ColorPalettesEnabled],
}),
getColorPalette: makeRoute({
route: 'GET /v1/color-palettes/:colorPaletteId',
handler: colorPalettesController.get,
authPolicy: AuthPolicy.disabled,
feat: [Feature.ColorPalettesEnabled],
features: [Feature.ColorPalettesEnabled],
}),
createColorPalette: makeRoute({
route: 'POST /v1/color-palettes',
handler: colorPalettesController.create,
write: true,
feat: [Feature.ColorPalettesEnabled],
features: [Feature.ColorPalettesEnabled],
}),
updateColorPalette: makeRoute({
route: 'POST /v1/color-palettes/:colorPaletteId/update',
handler: colorPalettesController.update,
write: true,
feat: [Feature.ColorPalettesEnabled],
features: [Feature.ColorPalettesEnabled],
}),
deleteColorPalette: makeRoute({
route: 'DELETE /v1/color-palettes/:colorPaletteId',
handler: colorPalettesController.delete,
write: true,
feat: [Feature.ColorPalettesEnabled],
features: [Feature.ColorPalettesEnabled],
}),
} as const;

Expand Down

0 comments on commit d44bb9a

Please sign in to comment.