Initial commit
This commit is contained in:
20
cli-post.mjs
Normal file
20
cli-post.mjs
Normal file
@@ -0,0 +1,20 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user