Skip to content

Commit 524cb8e

Browse files
committed
fix: correct return, correct order
1 parent ff359ba commit 524cb8e

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export class Evaluator {
309309
return reject(new Error(response.error));
310310
}
311311

312-
return resolve(response.result);
312+
return resolve(response.result.code);
313313
}
314314
};
315315

src/server/socket.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ export class EvalSocket {
7979
);
8080
}
8181

82-
if (
83-
!data?.id ||
84-
typeof data.id !== 'string' ||
85-
!data?.code ||
86-
typeof data.code !== 'string'
87-
) {
82+
if (!data?.id || typeof data.id !== 'string') {
8883
return this.send(
8984
client,
9085
{ error: 'Invalid or missing ID.' },
@@ -100,6 +95,14 @@ export class EvalSocket {
10095
return awaiter.resolve(data);
10196
}
10297

98+
if (!data?.code || typeof data.code !== 'string') {
99+
return this.send(
100+
client,
101+
{ error: 'Invalid or missing ID.' },
102+
EventCode.MALFORMED_DATA,
103+
);
104+
}
105+
103106
const response = await this.handleEvalRequest(data.code, data.msg);
104107
this.send(client, {
105108
...response,

0 commit comments

Comments
 (0)