diff --git a/.env.example b/.env.example index 2ba1a61..79c885e 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ CLOUDFLARE_API_TOKEN= MONGODB_URI= +SG_CARS_TRENDS_API_TOKEN= diff --git a/.github/workflows/sst.prod.yml b/.github/workflows/sst.prod.yml index 97708fa..f7fa04e 100644 --- a/.github/workflows/sst.prod.yml +++ b/.github/workflows/sst.prod.yml @@ -21,6 +21,7 @@ jobs: env: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} MONGODB_URI: ${{ secrets.MONGODB_URI }} + SG_CARS_TRENDS_API_TOKEN: ${{ secrets.SG_CARS_TRENDS_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 diff --git a/.github/workflows/sst.staging.yml b/.github/workflows/sst.staging.yml index 0ca0fdd..78a85fc 100644 --- a/.github/workflows/sst.staging.yml +++ b/.github/workflows/sst.staging.yml @@ -2,6 +2,8 @@ name: Deployment (Staging) on: push: + branches: + - "*" tags-ignore: - '*' @@ -19,6 +21,7 @@ jobs: env: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} MONGODB_URI: ${{ secrets.MONGODB_URI }} + SG_CARS_TRENDS_API_TOKEN: ${{ secrets.SG_CARS_TRENDS_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 diff --git a/env.d.ts b/env.d.ts index 984cac5..96f350b 100644 --- a/env.d.ts +++ b/env.d.ts @@ -2,5 +2,6 @@ declare namespace NodeJS { export interface ProcessEnv { CLOUDFLARE_API_TOKEN: string; MONGODB_URI: string; + SG_CARS_TRENDS_API_TOKEN: string; } } diff --git a/src/index.ts b/src/index.ts index 252dd37..43d09e8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import { Hono } from "hono"; import { handle } from "hono/aws-lambda"; +import { bearerAuth } from "hono/bearer-auth"; import { compress } from "hono/compress"; import { showRoutes } from "hono/dev"; import { logger } from "hono/logger"; @@ -10,6 +11,7 @@ import v1 from "./v1"; const app = new Hono(); +app.use(bearerAuth({ token: process.env.SG_CARS_TRENDS_API_TOKEN })); app.use(logger()); app.use(compress()); app.use(prettyJSON()); diff --git a/sst.config.ts b/sst.config.ts index 553be0a..f663070 100644 --- a/sst.config.ts +++ b/sst.config.ts @@ -45,6 +45,7 @@ export default $config({ description: "API for LTA Cars Datasets", environment: { MONGODB_URI: process.env.MONGODB_URI, + SG_CARS_TRENDS_API_TOKEN: process.env.SG_CARS_TRENDS_API_TOKEN, }, handler: "src/index.handler", url: {