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: about 1 year 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 (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-13T17:04:41.000Z (about 3 years ago)
- Last Synced: 2025-03-17T12:06:39.918Z (over 1 year 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: 3
- 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.
[](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)