diff --git a/example/bun.lockb b/example/bun.lockb index 0ce0331..1d27f46 100755 Binary files a/example/bun.lockb and b/example/bun.lockb differ diff --git a/example/package.json b/example/package.json index 633de7b..bef8b2f 100644 --- a/example/package.json +++ b/example/package.json @@ -13,6 +13,6 @@ "typescript": "^5.0.0" }, "dependencies": { - "@muzamint/erica-items-db": "^0.0.0" + "@muzamint/erica-items-db": "latest" } } diff --git a/example/src/index.ts b/example/src/index.ts index be7cce6..15a13cc 100644 --- a/example/src/index.ts +++ b/example/src/index.ts @@ -1,4 +1,3 @@ -console.log("Hello via Bun!"); import { router } from '@muzamint/erica-items-db' export default { diff --git a/package.json b/package.json index 6bb42f5..380630a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@muzamint/erica-items-db", - "version": "0.0.1", + "version": "0.1.0", "main": "dist/index.js", "types": "dist/index.d.ts", "description": "", diff --git a/src/index.ts b/src/index.ts index efdc451..4a6809e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,16 +1,16 @@ export const one = 1 export const two = 2 import { http, createPublicClient, webSocket } from 'viem' -import { mainnet } from 'viem/chains' +import * as ChainList from 'viem/chains' export * from './items' const client = createPublicClient({ - chain: mainnet, + chain: ChainList.mainnet, transport: http(), }) const webSocketClient = createPublicClient({ - chain: mainnet, + chain: ChainList.mainnet, transport: webSocket( 'wss://eth-mainnet.g.alchemy.com/v2/4iIl6mDHqX3GFrpzmfj2Soirf3MPoAcH', ), diff --git a/src/items/interface/item.ts b/src/items/interface/item.ts index 5cfda58..3a257f7 100644 --- a/src/items/interface/item.ts +++ b/src/items/interface/item.ts @@ -1,10 +1,8 @@ // src/items/item.interface.ts +import type { Chain } from 'viem/chains' export interface BaseItem { - name: string; - price: number; - description: string; - image: string; + meta: Chain; } export interface Item extends BaseItem { diff --git a/src/items/router/items.ts b/src/items/router/items.ts index da7f04b..9ca9dae 100644 --- a/src/items/router/items.ts +++ b/src/items/router/items.ts @@ -22,7 +22,7 @@ export const router = new Elysia() return new Response(error.toString()) }) .get('/ping', () => 'pong') - .group("/items", app => { + .group("api/v1/chainlist", app => { return app .get('/', async () => await ItemService.findAll() ) .post('/', async ({ body, set }) => { diff --git a/src/items/service/items.ts b/src/items/service/items.ts index 2c604f5..79f4adb 100644 --- a/src/items/service/items.ts +++ b/src/items/service/items.ts @@ -4,33 +4,15 @@ import { BaseItem, Item } from "../interface/item"; import { Items } from "../interface/items"; +import * as ChainList from 'viem/chains'; -// in memory store - -let items: Items = { - 1: { - id: 1, - name: "Burger", - price: 599, - description: "Tasty", - image: "https://cdn.auth0.com/blog/whatabyte/burger-sm.png" - }, - 2: { - id: 2, - name: "Pizza", - price: 299, - description: "Cheesy", - image: "https://cdn.auth0.com/blog/whatabyte/pizza-sm.png" - }, - 3: { - id: 3, - name: "Tea", - price: 199, - description: "Informative", - image: "https://cdn.auth0.com/blog/whatabyte/tea-sm.png" - } -}; +var chainlist = [] +var id_counter = 0; +for(var i in Object.keys(ChainList)) + chainlist.push({id: id_counter++, meta: Object.values(ChainList)[i]}); +// in memory store +let items: Items = chainlist as any[] // services export const findAll = async (): Promise => Object.values(items);