README
@lpgroup/import-cli
Cli command that imports data into rest-api, RabbitMQ and NATS.
Install
Installation of the npm
npm install @lpgroup/import-cli
Configuration
.import.json
{
"environments": {
"default": {
"http": {
"server": "https://api.thecatapi.com/v1/",
"user": "",
"password": "",
"readyServer": "https://api.thecatapi.com/",
"headers": { "x-api-key": "446825e1-284d-4d4d-8fc7-7556636211ad" }
},
"nats": { "uri": "nats://localhost:4222", "queue": "import-js", "messagePrefix": "int" },
"rabbitmq": {
"uri": "amqps://user:password@xxxx.cloudamqp.com/user",
"queue": "dev"
}
}
},
"requiredKeys": ["owner", "added", "changed", "url"],
"ignoreKeyCompare": ["_id", "owner", "added", "changed", "url"]
}
Example
Add the following to import/10-votes.js
.
import { axios } from "@lpgroup/import-cli";
export default async () => {
return axios().then(async (ax) => {
await ax.post("/votes", {
image_id: "good-cat",
sub_id: "my-user-1234",
value: 1,
});
});
};
Add the follwing script to package.json
.
{
"scripts": {
"import": "import-cli -v -e default -w import/"
}
}
Run script from command line.
npm run import -- -i 10-votes
Contribute
See contribute
License
MIT - See licence