Skip to content

Commit

Permalink
feat: add get publishing endpoint (CT-000) (#428)
Browse files Browse the repository at this point in the history
<!-- You can erase any parts of this template not applicable to your Pull Request. -->

**Fixes or implements VF-000**

### Brief description. What is this change?
Added a new endpoint: 
`GET /public/:projectID/publishing` - this fetches the `version.platformData.publishing` field of a PUBLIC project

because of the `resolvePublicProjectID` middleware, the project's `project.apiPrivacy` must be public to get this information. This is important to expose because it allows us to fetch project settings and metadata from the adapters/clients.

Co-authored-by: Tyler Han <tylerhan97@gmail.com>
  • Loading branch information
DecathectZero and DecathectZero committed Oct 17, 2022
1 parent a70c4c9 commit 1630696
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/api/routers/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ export default (middlewares: MiddlewareMap, controllers: ControllerMap) => {
controllers.stateManagement.publicInteract
);

router.get('/:projectID/publishing', interactMiddleware, controllers.stateManagement.getPublicPublishing);

return router;
};
11 changes: 11 additions & 0 deletions lib/controllers/stateManagement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ class StateManagementController extends AbstractController {
return { trace };
}

@validate({
HEADERS_VERSION_ID: VALIDATIONS.HEADERS.VERSION_ID,
})
async getPublicPublishing(req: Request<{ userID: string }, never, { versionID: string }>) {
const api = await this.services.dataAPI.get();

const version = await api.getVersion(req.headers.versionID);

return version.platformData.publishing || {};
}

@validate({ HEADERS_PROJECT_ID: VALIDATIONS.HEADERS.PROJECT_ID })
async get(req: Request<{ userID: string }, any, { projectID: string }>) {
return this.services.session.getFromDb(req.headers.projectID, req.params.userID);
Expand Down

0 comments on commit 1630696

Please sign in to comment.