Skip to content

Commit

Permalink
add get(id)
Browse files Browse the repository at this point in the history
  • Loading branch information
mingder78 committed Dec 12, 2023
1 parent 1844a6c commit 43524d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": "",
Expand Down
9 changes: 8 additions & 1 deletion src/items/router/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
Expand Down

0 comments on commit 43524d7

Please sign in to comment.