Skip to content

Commit

Permalink
feat(console): optional express app for server (#4148)
Browse files Browse the repository at this point in the history
the console server now accepts an optional express app. useful for setting up authentication and other routes prior to the console routes

## Checklist

- [X] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [X] Description explains motivation and solution
- [ ] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
eladcon authored Sep 13, 2023
1 parent a315139 commit d280fb3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/wing-console/console/app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface CreateConsoleAppOptions {
requestedPort?: number;
hostUtils?: HostUtils;
onTrace?: (trace: Trace) => void;
expressApp?: express.Express;
onExpressCreated?: CreateConsoleServerOptions["onExpressCreated"];
requireAcceptTerms?: boolean;
layoutConfig?: LayoutConfig;
Expand Down
4 changes: 3 additions & 1 deletion apps/wing-console/console/server/src/expressServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface CreateExpressServerOptions {
requestedPort?: number;
appState(): State;
hostUtils?: HostUtils;
expressApp?: express.Express;
onExpressCreated?: (app: express.Express) => void;
wingfile: string;
requireAcceptTerms?: boolean;
Expand All @@ -55,6 +56,7 @@ export const createExpressServer = async ({
requestedPort,
appState,
hostUtils,
expressApp,
onExpressCreated,
wingfile,
requireAcceptTerms = false,
Expand All @@ -63,7 +65,7 @@ export const createExpressServer = async ({
setSelectedNode,
testsStateManager,
}: CreateExpressServerOptions) => {
const app = express();
const app = expressApp ?? express();
app.use(cors());

const { router } = mergeAllRouters();
Expand Down
7 changes: 5 additions & 2 deletions apps/wing-console/console/server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { inferRouterInputs } from "@trpc/server";
import Emittery from "emittery";
import type { Application as ExpressApplication } from "express";
import type { Express } from "express";

import type { Config } from "./config.js";
import { type ConsoleLogger, createConsoleLogger } from "./consoleLogger.js";
Expand Down Expand Up @@ -57,7 +57,8 @@ export interface CreateConsoleServerOptions {
requestedPort?: number;
hostUtils?: HostUtils;
onTrace?: (trace: Trace) => void;
onExpressCreated?: (app: ExpressApplication) => void;
expressApp?: Express;
onExpressCreated?: (app: Express) => void;
requireAcceptTerms?: boolean;
layoutConfig?: LayoutConfig;
}
Expand All @@ -70,6 +71,7 @@ export const createConsoleServer = async ({
requestedPort,
hostUtils,
onTrace,
expressApp,
onExpressCreated,
requireAcceptTerms,
layoutConfig,
Expand Down Expand Up @@ -224,6 +226,7 @@ export const createConsoleServer = async ({
return appState;
},
hostUtils,
expressApp,
onExpressCreated,
wingfile,
requireAcceptTerms,
Expand Down

0 comments on commit d280fb3

Please sign in to comment.