Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mateonunez/lyra-impact
Create a Lyra database from anywhere. Full REST API supported, GraphQL and CSVs.
https://github.com/mateonunez/lyra-impact
database filesystem graphql impact lyra plugin rest
Last synced: 20 days ago
JSON representation
Create a Lyra database from anywhere. Full REST API supported, GraphQL and CSVs.
- Host: GitHub
- URL: https://github.com/mateonunez/lyra-impact
- Owner: mateonunez
- License: mit
- Created: 2022-08-21T12:49:47.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-13T17:04:41.000Z (over 1 year ago)
- Last Synced: 2024-10-18T06:27:01.785Z (about 1 month ago)
- Topics: database, filesystem, graphql, impact, lyra, plugin, rest
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@mateonunez/lyra-impact
- Size: 168 KB
- Stars: 9
- Watchers: 4
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🌍☄️️ Impact
Create a [Lyra](https://github.com/lyrasearch/lyra) database from anywhere.
[![Tests](https://github.com/mateonunez/lyra-impact/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/mateonunez/lyra-impact/actions/workflows/ci.yml)
## Installation
You can install Lyra using `npm`, `yarn`, `pnpm`:
```sh
npm i @mateonunez/lyra-impact
```
```sh
yarn add @mateonunez/lyra-impact
```
```sh
pnpm add @mateonunez/lyra-impact
```## Examples
See the full list of examples: [mateonunez/lyra-impact-examples](https://github.com/mateonunez/lyra-impact-examples)
- [React](https://lyra-impact-examples-with-react.vercel.app/)
- [Vue](https://lyra-impact-examples-with-vue.vercel.app/)
- [Supercharged](https://lyra-impact-supercharged.vercel.app/)## Usage
```js
import { search } from "@lyrasearch/lyra"
import { impact } from "@mateonunez/lyra-impact"(async () => {
const lyra = await impact("https://raw.githubusercontent.com/LyraSearch/lyra/main/examples/with-vue/public/pokedex.json")const { hits } = await search(lyra, { term: "pikachu" })
console.log(hits)
})();
```**Result**
```js
[
{
num: '025',
name: 'Pikachu',
img: 'http://www.serebii.net/pokemongo/pokemon/025.png',
type: [ 'Electric' ],
height: '0.41 m',
weight: '6.0 kg',
candy: 'Pikachu Candy',
candy_count: 50,
egg: '2 km',
spawn_chance: 0.21,
avg_spawns: 21,
spawn_time: '04:00',
multipliers: [ 2.34 ],
weaknesses: [ 'Ground' ],
next_evolution: [ { num: '026', name: 'Raichu' } ]
}
];
```## Formats and fetchers
`lyra-impact` supports the following formats and fetchers:
| Format | Fetcher | Description |
| ----------------- | --------------------- | ----------------------------------------------- |
| `JSON` | `fetch`, `filesystem` | Fetches a **JSON** response or file |
| `GraphQL` | `graphql` | Fetches a **GraphQL** endpoint |
| `CSV` | `fetch`, `filesystem` | Fetches a **CSV** file from a URL or filesystem |
| `XML` (_REMOVED_) | `fetch`, `filesystem` | Fetches a **XML** file from a URL or filesystem |### With GraphQL
```js
import { search } from "@lyrasearch/lyra"
import { impact } from "@mateonunez/lyra-impact"(async () => {
const lyra = await impact("https://rickandmortyapi.com/graphql", {
fetch: {
fetcher: "graphql",
query: `{
characters {
results {
type
status
species
name
id
gender
}
}
}`,
property: "characters.results"
}
})const { hits } = await search(lyra, {
term: "Morty"
})console.log(hits)
})()
```### With Filesystem
```js
import { search } from "@lyrasearch/lyra"
import { impact } from "@mateonunez/lyra-impact"(async () => {
const lyra = await impact("./data/examples/characters.csv", {
fetch: {
fetcher: "filesystem"
}
})const { hits } = await search(lyra, {
term: "Morty"
})console.log(hits)
})()
```### Collision
`collision` method allows you to fetch and search a **term** in the API results.
- `url: string`
- `searchOptions: SearchOptions`
- `impactOptions: ImpactOptions````js
import { collision } from "@mateonunez/lyra-impact"(async () => {
const { hits } = await collision("https://raw.githubusercontent.com/LyraSearch/lyra/main/examples/with-vue/public/pokedex.json", {
term: "pikachu"
})console.log(hits)
})();
```**Result**
```js
[
{
num: '025',
name: 'Pikachu',
img: 'http://www.serebii.net/pokemongo/pokemon/025.png',
type: [ 'Electric' ],
height: '0.41 m',
weight: '6.0 kg',
candy: 'Pikachu Candy',
candy_count: 50,
egg: '2 km',
spawn_chance: 0.21,
avg_spawns: 21,
spawn_time: '04:00',
multipliers: [ 2.34 ],
weaknesses: [ 'Ground' ],
next_evolution: [ { num: '026', name: 'Raichu' } ]
}
];```
# License
[MIT](/LICENSE)