21 lines
467 B
JavaScript
21 lines
467 B
JavaScript
import { readFile } from 'node:fs/promises';
|
|
|
|
const [, , resource, filename] = process.argv;
|
|
|
|
if (!resource || !filename) {
|
|
console.error('usage: node clip-post.mjs <resource_id> <filename>');
|
|
process.exit(1);
|
|
}
|
|
|
|
const data = await readFile(filename);
|
|
|
|
const res = await fetch(`http://localhost:3888/emit/${encodeURIComponent(resource)}`, {
|
|
method: 'POST',
|
|
body: data
|
|
});
|
|
|
|
if (res.status !== 204) {
|
|
console.error('POST failed:', res.status);
|
|
process.exit(1);
|
|
}
|