-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(frontend-api): duplicate frontend client endpoints to new /a…
…pi/v3 router (#1574) * refactor(frontend-api): duplicate frontend client endpoints to new /api/v3 router - duplicate frontend client endpoints functionality and update them to use the new api v3 routes - update v3 router to use new endpoints - update frontend api calls to use new endpoints * refactor(frontend-api): use updated frontend handlers * refactor(frontend-api): clean up routes and update comments * fix(frontend-api): fix /features route and clean up routes
- Loading branch information
1 parent
5ca787d
commit fffd972
Showing
6 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { celebrate, Joi, Segments } from 'celebrate' | ||
import { Router } from 'express' | ||
|
||
import * as FrontendServerController from '../../../../modules/frontend/frontend.controller' | ||
import { GoogleAnalyticsFactory } from '../../../../modules/frontend/google-analytics.factory' | ||
|
||
export const ClientRouter = Router() | ||
|
||
/** | ||
* Generate the templated Javascript code for the frontend to initialise Google Tag Manager | ||
* Code depends on whether googleAnalyticsFeature.isEnabled | ||
* @route GET /api/v3/client/analytics/google | ||
* @return 200 when code generation is successful | ||
* @return 400 when code generation fails | ||
*/ | ||
ClientRouter.get( | ||
'/analytics/google', | ||
GoogleAnalyticsFactory.addGoogleAnalyticsData, | ||
) | ||
|
||
/** | ||
* Generate the templated Javascript code with environment variables for the frontend | ||
* @route GET /api/v3/client/environment | ||
* @return 200 when code generation is successful | ||
* @return 400 when code generation fails | ||
*/ | ||
ClientRouter.get('/environment', FrontendServerController.addEnvVarData) | ||
|
||
/** | ||
* Generate a json of current activated features | ||
* @route GET /api/v3/client/features | ||
* @return json with featureManager.states | ||
*/ | ||
ClientRouter.get('/features', FrontendServerController.showFeaturesStates) | ||
|
||
/** | ||
* Generate the javascript code to redirect to the correct url | ||
* @route GET /api/v3/client/redirect | ||
* @return 200 when redirect code is successful | ||
* @return 400 when redirect code fails | ||
*/ | ||
ClientRouter.get( | ||
'/redirect', | ||
celebrate({ | ||
[Segments.QUERY]: { | ||
redirectPath: Joi.string() | ||
.regex(/^[a-fA-F0-9]{24}(\/(preview|template|use-template))?/) | ||
.required(), | ||
}, | ||
}), | ||
FrontendServerController.generateRedirectUrl, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { ClientRouter } from './client.routes' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters