blob: 59c2ffa33b06a67f60d55b0c3a22a9e92f8e81d9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import fetch from 'node-fetch';
export async function postHaste(code: string, lang?: string): Promise<string> {
try {
if (code.length > 400000) {
return 'Document exceeds maximum length.';
}
const res = await fetch('https://paste.nomsy.net/documents', { method: 'POST', body: code });
const { key, message } = await res.json();
if (!key) {
return message;
}
return `https://paste.nomsy.net/${key}${lang && `.${lang}`}`;
} catch (err) {
throw err;
}
}
|