Skip to content

Commit b323c43

Browse files
committed
FLS-1452 - Remove publishing endpoints
Publishing endpoints in Form Runner are used as Form Designer's primary persistence mechanism - each change made to a form in Form Designer will trigger a POST request to the /publish endpoint, updating the form configuration in the Runner's cache. They are also used as a means to allow FAB and Form Designer to offer form previews for forms that are not loaded into the Runner cache on app startup. Thus they are integral to the current functioning of the application, and this commit can very much be considered a potentially breaking change, so it's important that FAB and Form Designer are redirected at Pre-Award before this goes live. Why are we removing them then? They are components of a flawed system that is being revamped by Live Services as part of our forms re-architecture work. In the future, there will be no need for arbitrary forms to be published into the cache, in order to support persistence or preview. Forms will be stored in a new location - the Pre-Award database - and Form Designer will POST updated form configuration data to a Pre-Award API. And regarding form preview, for a form to even be shown in Form Designer or FAB it must exist in the Pre-Award database, and so rendering it from Form Designer or FAB will be a simple case of requesting the form directly from the Runner, which will get it from the Pre-Award API, with no precursor publish call necessary.
1 parent 01a084d commit b323c43

File tree

1 file changed

+0
-65
lines changed

1 file changed

+0
-65
lines changed

runner/src/server/plugins/engine/api/RegisterFormsApi.ts

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -12,71 +12,7 @@ import {jwtAuthStrategyName} from "../Auth";
1212
import {config} from "../../utils/AdapterConfigurationSchema";
1313

1414
export class RegisterFormsApi implements RegisterApi {
15-
16-
/**
17-
* The following publish endpoints (/publish, /published/{id}, /published)
18-
* are used from the designer for operating in 'preview' mode.
19-
* I.E. Designs saved in the designer can be accessed in the runner for viewing.
20-
* The designer also uses these endpoints as a persistence mechanism for storing and retrieving data
21-
* for its own purposes so if you're changing these endpoints you likely need to go and amend
22-
* the designer too!
23-
*/
2415
register(server: HapiServer) {
25-
server.route({
26-
method: "post",
27-
path: "/publish",
28-
options: {
29-
description: "See API-README.md file in the runner/src/server/plugins/engine/api",
30-
},
31-
handler: async (request: HapiRequest, h: HapiResponseToolkit) => {
32-
const {adapterCacheService} = request.services([]);
33-
const payload = request.payload as FormPayload;
34-
const {id, configuration} = payload;
35-
const parsedConfiguration =
36-
typeof configuration === "string"
37-
? JSON.parse(configuration)
38-
: configuration;
39-
if (parsedConfiguration.configuration) {
40-
await adapterCacheService.setFormConfiguration(id, parsedConfiguration, request.server)
41-
} else {
42-
await adapterCacheService.setFormConfiguration(id, {configuration: parsedConfiguration}, request.server)
43-
}
44-
return h.response({}).code(204);
45-
}
46-
});
47-
48-
server.route({
49-
method: "get",
50-
path: "/published/{id}",
51-
options: {
52-
description: "See API-README.md file in the runner/src/server/plugins/engine/api",
53-
},
54-
handler: async (request: HapiRequest, h: HapiResponseToolkit) => {
55-
const {id} = request.params;
56-
const {adapterCacheService} = request.services([]);
57-
const form = await adapterCacheService.getFormAdapterModel(id, request);
58-
if (!form) {
59-
return h.response({}).code(204);
60-
}
61-
const {values} = await adapterCacheService.getFormAdapterModel(id, request);
62-
return h.response(JSON.stringify({id, values})).code(200);
63-
}
64-
});
65-
66-
server.route({
67-
method: "get",
68-
path: "/published",
69-
options: {
70-
description: "See API-README.md file in the runner/src/server/plugins/engine/api",
71-
},
72-
handler: async (request: HapiRequest, h: HapiResponseToolkit) => {
73-
const {adapterCacheService} = request.services([]);
74-
return h
75-
.response(JSON.stringify(await adapterCacheService.getFormConfigurations(request)))
76-
.code(200);
77-
}
78-
});
79-
8016
server.route({
8117
method: "get",
8218
path: "/",
@@ -133,7 +69,6 @@ export class RegisterFormsApi implements RegisterApi {
13369
/**
13470
* Middleware to check if the user session is still valid.
13571
*
136-
* Changes behaviour only when previewMode is FALSE, meaning PRODUCTION
13772
* If the session is dropped, it will throw a client timeout error
13873
*/
13974
const checkUserSession = async (

0 commit comments

Comments
 (0)