Skip to content

Commit cbe02a4

Browse files
committed
dev: puterjs exec module
1 parent 77d6bb2 commit cbe02a4

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/backend/src/modules/puterexec/Judge0Client.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,22 @@ class Judge0Client {
4444
path = `/${path}`;
4545
}
4646

47-
const resp = await axios.request({
48-
method: 'POST',
49-
url: `${this.baseURL}${path}`,
50-
headers: {
51-
Authorization: `Bearer ${this.token}`,
52-
'Content-Type': 'application/json',
53-
},
54-
data,
55-
});
47+
try {
48+
const resp = await axios.request({
49+
method: 'POST',
50+
url: `${this.baseURL}${path}`,
51+
headers: {
52+
Authorization: `Bearer ${this.token}`,
53+
'Content-Type': 'application/json',
54+
},
55+
data,
56+
});
5657

57-
return resp.data;
58+
return resp.data;
59+
} catch (e) {
60+
console.error('error response', e.response.data);
61+
throw e;
62+
}
5863
}
5964
}
6065

src/backend/src/services/drivers/DriverService.js

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class DriverService extends BaseService {
216216
['puter-tts']: 'aws-polly',
217217
['puter-chat-completion']: 'openai-completion',
218218
['puter-image-generation']: 'openai-image-generation',
219+
'puter-exec': 'judge0',
219220
'puter-apps': 'es:app',
220221
'puter-subdomains': 'es:subdomain',
221222
'puter-notifications': 'es:notification',

src/puter-js/src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { PSocket, wispInfo } from './modules/networking/PSocket.js';
2323
import { PTLSSocket } from "./modules/networking/PTLS.js"
2424
import { PWispHandler } from './modules/networking/PWispHandler.js';
2525
import { make_http_api } from './lib/http.js';
26+
import Exec from './modules/Exec.js';
2627

2728
// TODO: This is for a safe-guard below; we should check if we can
2829
// generalize this behavior rather than hard-coding it.
@@ -98,6 +99,7 @@ window.puter = (function() {
9899
this.registerModule('kv', KV);
99100
this.registerModule('drivers', Drivers);
100101
this.registerModule('debug', Debug);
102+
this.registerModule('exec', Exec);
101103

102104
// Path
103105
this.path = path;

0 commit comments

Comments
 (0)