fail build drone
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

pull/2/head
Hugo PRADIER 11 months ago
parent 31d3b6403a
commit 49cf852117

@ -1,8 +1,12 @@
export const RUNNERS = ['bash', 'moshell', 'bun', 'typescript'] as const;
export const RUNNERS = ["bash", "moshell", "bun", "typescript"] as const;
const ALLOWED_LANGUAGES = new Set<string>(RUNNERS);
const aliases: Record<string, typeof RUNNERS[number]> = {
'JavaScript': 'bun',
'TypeScript': 'typescript',
const aliases: Record<string, (typeof RUNNERS)[number]> = {
JavaScript: "bun",
TypeScript: "typescript",
};
export const IMAGES = {
logo: "logo.png",
background: "background.png",
};
/**
@ -12,9 +16,15 @@ const aliases: Record<string, typeof RUNNERS[number]> = {
* @param code The code to be executed.
* @param image The image to be used.
*/
export function allocateBuffer(jobId: string, code: string, image: string): Buffer {
export function allocateBuffer(
jobId: string,
code: string,
image: string
): Buffer {
let cur = 0;
const buffer = Buffer.allocUnsafe(jobId.length + image.length + code.length + 9);
const buffer = Buffer.allocUnsafe(
jobId.length + image.length + code.length + 9
);
cur = buffer.writeUInt8(0, cur);
cur += buffer.write(jobId, cur);
cur = buffer.writeUInt32BE(image.length, cur);
@ -24,10 +34,10 @@ export function allocateBuffer(jobId: string, code: string, image: string): Buff
return buffer;
}
export function getRunner(language: string): typeof RUNNERS[number] | null {
export function getRunner(language: string): (typeof RUNNERS)[number] | null {
language = aliases[language] || language;
if (ALLOWED_LANGUAGES.has(language)) {
return language as typeof RUNNERS[number];
return language as (typeof RUNNERS)[number];
}
return null;
}

@ -7,6 +7,8 @@ import { Pull, Push } from "zeromq";
import * as db from "./database";
console.log(IMAGES.logo);
const sender = new Push();
await sender.bind(`tcp://127.0.0.1:5557`);
const receiver = new Pull();

Loading…
Cancel
Save