PromucFlow_constructor/app/client/packages/rts/src/server.ts
Rudraprasad Das 71d67185c4
feat: dsl migration with server (#28518)
## Description
1. Shifts DSL migration logic to @shared/dsl
2. Exposes /migrate/dsl endpoint on rts
3. Integrates RTS endpoint to backend for serving migrated pages
4. Introduces feature flag to switch between client-based and
server-based on-demand migration

#### PR fixes following issue(s)
Fixes #26783, #26784, #26980 

#### Type of change
- New feature (non-breaking change which adds functionality)

## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [x] Manual
- [ ] JUnit
- [x] Jest
- [x] Cypress
>
>
#### Test Plan
> Add Testsmith test cases links that relate to this PR
>
>
#### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
>
>
>
## Checklist:
#### Dev activity
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed

---------

Co-authored-by: Nayan <nayan@appsmith.com>
2023-11-30 18:03:33 +05:30

57 lines
1.7 KiB
TypeScript

import http from "http";
import express from "express";
import { Server } from "socket.io";
import type { LogLevelDesc } from "loglevel";
import log from "loglevel";
import { VERSION as buildVersion } from "./version"; // release version of the api
import { initializeSockets } from "./sockets";
// routes
import ast_routes from "./routes/ast_routes";
import dsl_routes from "./routes/dsl_routes";
import health_check_routes from "./routes/health_check_routes";
const RTS_BASE_PATH = "/rts";
export const RTS_BASE_API_PATH = "/rts-api/v1";
// Setting the logLevel for all log messages
const logLevel: LogLevelDesc = (process.env.APPSMITH_LOG_LEVEL ||
"debug") as LogLevelDesc;
log.setLevel(logLevel);
const API_BASE_URL = process.env.APPSMITH_API_BASE_URL;
if (API_BASE_URL == null || API_BASE_URL === "") {
log.error("Please provide a valid value for `APPSMITH_API_BASE_URL`.");
process.exit(1);
}
const APPSMITH_RTS_PORT = process.env.APPSMITH_RTS_PORT || 8091;
//Disable x-powered-by header to prevent information disclosure
const app = express();
app.disable("x-powered-by");
const server = new http.Server(app);
const io = new Server(server, {
path: RTS_BASE_PATH,
});
initializeSockets(io);
// parse incoming json requests
app.use(express.json({ limit: "5mb" }));
app.use(`${RTS_BASE_API_PATH}/ast`, ast_routes);
app.use(`${RTS_BASE_API_PATH}/dsl`, dsl_routes);
app.use(`${RTS_BASE_API_PATH}`, health_check_routes);
server.headersTimeout = 61000;
server.keepAliveTimeout = 60000;
// Run the server
server.listen(APPSMITH_RTS_PORT, () => {
log.info(
`RTS version ${buildVersion} running at http://localhost:${APPSMITH_RTS_PORT}`,
);
});
export default server;