Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions workspaces/server/src/endpoints/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { context } from "../ALS.js";

export async function get(_req: Request, res: Response) {
try {
res.writeHead(200, {
"Content-Type": "text/html"
});

const { viewBuilder } = context.getStore()!;

const templateStr = await viewBuilder.render();

res.writeHead(200, {
"Content-Type": "text/html"
});
res.end(templateStr);
}
catch (err: any) {
Expand Down
36 changes: 0 additions & 36 deletions workspaces/server/test/httpServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { type Polka } from "polka";

// Import Internal Dependencies
import { buildServer } from "../index.js";
import * as rootEndpoint from "../src/endpoints/root.js";
import * as flagsEndpoint from "../src/endpoints/flags.js";

// CONSTANTS
Expand Down Expand Up @@ -82,41 +81,6 @@ describe("httpServer", { concurrency: 1 }, () => {
assert.equal(result.headers["content-type"], "text/html");
});

test("'/' should fail", async(ctx) => {
class Response {
body: string;
headers: Record<string, string>;
statusCode: number;

constructor() {
this.body = "";
this.headers = {};
this.statusCode = 200;
}
end(str: string) {
this.body = str;
}
writeHead(int: number) {
this.statusCode = int;
}
getHeader(key: string) {
return this.headers[key];
}
}

const fakeError = "fake error";
function toThrow() {
throw new Error(fakeError);
}
ctx.mock.method(Response.prototype, "writeHead", toThrow, { times: 1 });

const response: any = new Response();
await rootEndpoint.get({} as any, response);

assert.strictEqual(response.body, JSON.stringify({ error: fakeError }));
assert.strictEqual(response.statusCode, 500);
});

test("'/flags' should return the flags list as JSON", async() => {
const result = await get(new URL("/flags", kHttpURL));

Expand Down
Loading