diff --git a/package.json b/package.json index 380630a..67e09f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@muzamint/erica-items-db", - "version": "0.1.0", + "version": "0.1.1", "main": "dist/index.js", "types": "dist/index.d.ts", "description": "", diff --git a/src/items/router/items.ts b/src/items/router/items.ts index 9ca9dae..e4b9eb8 100644 --- a/src/items/router/items.ts +++ b/src/items/router/items.ts @@ -24,7 +24,7 @@ export const router = new Elysia() .get('/ping', () => 'pong') .group("api/v1/chainlist", app => { return app - .get('/', async () => await ItemService.findAll() ) + .get('/', async () => await ItemService.findAll()) .post('/', async ({ body, set }) => { const newItem: Item = await ItemService.create(body as BaseItem); set.status = 200 @@ -42,6 +42,13 @@ export const router = new Elysia() return { success: false }; } }) + .get("/:id", async ({ params }) => { + try { + return await ItemService.find(parseInt(params.id)); + } catch (e) { + return { success: false }; + } + }) }) .get('/', () => { throw new CustomError('Hello Error');