dotfiles/bin/nocodb.mjs

21 lines
776 B
JavaScript
Raw Normal View History

2024-02-19 20:37:09 +01:00
#!/usr/bin/env nodejsscript
/* jshint esversion: 11,-W097, -W040, module: true, node: true, expr: true, undef: true *//* global echo, $, pipe, s, fetch, cyclicLoop */
2024-03-21 10:35:30 +01:00
import { kwallet } from "./§kwallet.mjs";
2024-02-19 20:37:09 +01:00
const url_api= "https://nocodb.jaandrle.cz/api/v1/db/data/v1/Linky/Linky";
$.api()
.command("add-md")
.action(async function addMd(){
const { clipboard }= $;
const [ title, url ]= clipboard.split("](");
const res= await fetch(url_api, {
body: JSON.stringify({ Popis: title.slice(1), Url: url.slice(0, -1) }),
2024-03-21 10:35:30 +01:00
headers: { "xc-token": kwallet([ "readPassword", "Passwords", "nocodb-linky" ])[0].toString(),
2024-02-19 20:37:09 +01:00
"accept": "application/json", "Content-Type": "application/json"
},
method: "post"
}).then(res=>res.json());
echo(res);
})
.parse();