Skip to content

Commit a1a9613

Browse files
authored
Merge pull request #655 from joshuafcole/fix/server-client-eagerness
Fix/server client eagerness
2 parents 6cb08e6 + d3d26ec commit a1a9613

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/runtime/server.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,32 @@ function createExpressApp() {
112112
app.get("/build/*", handleStatic);
113113

114114
app.get("*", (request, response) => {
115-
let client = new HTTPRuntimeClient();
116-
let content = "";
117-
if(filepath) content = fs.readFileSync(filepath).toString();
118-
client.load(content, "user");
119-
client.handle(request, response);
120-
if(!client.server.handling) {
115+
let client;
116+
// @FIXME: When Owner.both is added this needs updated.
117+
if(config.runtimeOwner === Owner.server) {
118+
client = new HTTPRuntimeClient();
119+
let content = "";
120+
if(filepath) content = fs.readFileSync(filepath).toString();
121+
client.load(content, "user");
122+
client.handle(request, response);
123+
}
124+
if(config.runtimeOwner === Owner.client || client && !client.server.handling) {
121125
response.setHeader("Content-Type", `${contentTypes["html"]}; charset=utf-8`);
122126
response.end(fs.readFileSync(path.join(config.eveRoot, "index.html")));
123127
}
124128
});
125129

126130
app.post("*", (request, response) => {
127-
let client = new HTTPRuntimeClient();
128-
let content = "";
129-
if(filepath) content = fs.readFileSync(filepath).toString();
130-
client.load(content, "user");
131-
client.handle(request, response);
132-
if(!client.server.handling) {
131+
let client;
132+
// @FIXME: When Owner.both is added this needs updated.
133+
if(config.runtimeOwner === Owner.server) {
134+
client = new HTTPRuntimeClient();
135+
let content = "";
136+
if(filepath) content = fs.readFileSync(filepath).toString();
137+
client.load(content, "user");
138+
client.handle(request, response);
139+
}
140+
if(config.runtimeOwner === Owner.client || client && !client.server.handling) {
133141
return response.status(404).send("Looks like that asset is missing.");
134142
}
135143
});

0 commit comments

Comments
 (0)