diff --git a/Dockerfile b/Dockerfile index 0aff8fa..5ccb256 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ COPY bun.lockb . RUN /root/.bun/bin/bun install # ? ------------------------- + FROM gcr.io/distroless/base-debian11 WORKDIR /app diff --git a/bun.lockb b/bun.lockb index 052affc..a3722ca 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 3db16a4..d99c81b 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,19 @@ { "name": "thai-lotto-api", "version": "1.0.16", + "module": "src/index.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "bun run --hot src/index.ts" }, "dependencies": { - "@elysiajs/cors": "^0.3.0", - "@elysiajs/swagger": "^0.4.0", - "cheerio": "^1.0.0-rc.12", - "elysia": "^0.4.15", - "elysia-rate-limit": "^1.0.3" + "@elysiajs/cors": "0.7.1", + "@elysiajs/swagger": "0.7.4", + "cheerio": "1.0.0-rc.12", + "elysia": "0.7.24", + "elysia-rate-limit": "1.2.0" }, "devDependencies": { - "bun-types": "latest" - }, - "module": "src/index.js" -} \ No newline at end of file + "bun-types": "1.0.7" + } +} diff --git a/src/index.ts b/src/index.ts index 96da378..3c7fa62 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,7 +42,7 @@ const app = new Elysia() // }, }) ) - .setModel(model) + .model(model) .get('/', ({ set }) => (set.redirect = '/swagger')) .get('/ping', () => ({ status: 'success', @@ -67,7 +67,7 @@ const app = new Elysia() } }, { - transform({ params, set }) { + beforeHandle({ params, set }) { params.page = +params.page if (!Number.isSafeInteger(params.page)) { @@ -78,18 +78,18 @@ const app = new Elysia() } } }, + params: t.Object({ + page: t.Number(), + }), + response: { + 200: 'lotto.overview', + 400: 'api.error', + }, schema: { detail: { summary: 'Get lotto by page', tags: ['lotto'], }, - params: t.Object({ - page: t.Number(), - }), - response: { - 200: 'lotto.overview', - 400: 'api.error', - }, }, } ) @@ -130,20 +130,7 @@ const app = new Elysia() } }, { - schema: { - detail: { - summary: 'Check lottery status by lottery number', - tags: ['lotto'], - }, - params: t.Object({ - id: t.String(), - }), - response: { - 200: 'lotto.detail', - 400: 'api.error', - }, - }, - transform({ params, set }) { + beforeHandle({ params, set }) { if (!Number.isSafeInteger(Number(params.id))) { set.status = 400 return { @@ -152,6 +139,19 @@ const app = new Elysia() } } }, + params: t.Object({ + id: t.String(), + }), + response: { + 200: 'lotto.detail', + 400: 'api.error', + }, + schema: { + detail: { + summary: 'Check lottery status by lottery number', + tags: ['lotto'], + }, + }, } ) .get( @@ -186,15 +186,15 @@ const app = new Elysia() } }, { + response: { + 200: 'lotto.detail', + 400: 'api.error', + }, schema: { detail: { summary: 'Latest price annoucement', tags: ['lotto'], }, - response: { - 200: 'lotto.detail', - 400: 'api.error', - }, }, } )