-
Notifications
You must be signed in to change notification settings - Fork 10
rewrite: elysia → hono #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8e16505
fef6e60
bfd65bd
72820c2
734c04b
d89c398
9b30c1f
0db2d90
83a32b8
018a748
ce5a9b5
4070dc8
0862809
2becfe7
823b8f1
8a5fe43
6d43f9d
f7865ee
eff14df
06b5f3d
1895baf
51599ca
c931ccb
96cc5c4
0847f5d
37f7212
8f316fd
cc9d54b
5c4400b
f59e3c7
d2e5ef7
d9309d6
080217d
e9a36ea
9cae214
78b1c24
d5c8e35
b4dbf26
75c2e9f
bcdc988
af84349
3eabccf
1a13e5e
9a6b6f8
04ebd66
d7e7d9a
1cfe62e
2e1542b
d11af43
7b577d0
babecf4
b0e0713
1e5e190
83a80d2
1dc9ad2
4961097
3812318
7f2c387
fb0b4b4
463057d
24a0f28
b756bfe
250edd0
6bd135d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,6 @@ | ||||||||||
| DATABASE_URL="postgresql://comuline:password@localhost:5432/comuline" | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment: Hardcoded sensitive information in environment variables. Solution: Use environment variables or secret management tools to handle sensitive information securely.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment: Hardcoded sensitive information in environment variables. Solution: Use environment variables or secrets management tools to store sensitive information securely.
Suggested change
|
||||||||||
| COMULINE_ENV="development" | ||||||||||
|
|
||||||||||
| # Take token from .env.db | ||||||||||
| UPSTASH_REDIS_REST_TOKEN="" | ||||||||||
| UPSTASH_REDIS_REST_URL="http://localhost:8079" | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,10 @@ | ||
| # PostgreSQL | ||
| POSTGRES_USER="comuline" | ||
| POSTGRES_PASSWORD="password" | ||
| POSTGRES_DB="comuline" | ||
| POSTGRES_DB="comuline" | ||
|
|
||
| # Redis | ||
| SRH_MODE=env | ||
| # openssl rand -base64 32 | ||
| SRH_TOKEN="1Pf91ZNy5LDTKG621uhX/E73P8RmhVZu43kIV/WCmHg=" | ||
| SRH_CONNECTION_STRING=redis://redis:6379 |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Build API on Pull Request | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: ["main"] | ||
| types: [opened, reopened, synchronize] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build-test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: "latest" | ||
|
|
||
| - name: Install package deps | ||
| run: bun i | ||
|
|
||
| - name: Build package | ||
| run: bun run build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Deploy API to Cloudflare Workers | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Installing Bun | ||
| uses: oven-sh/setup-bun@v2 | ||
|
|
||
| - name: Install package deps | ||
| run: bun i | ||
|
|
||
| - name: Build package | ||
| run: bun run build | ||
|
|
||
| - name: Deploy to Cloudflare Workers | ||
| uses: cloudflare/wrangler-action@v3 | ||
| with: | ||
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| command: deploy --minify src/index.ts |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,3 +41,9 @@ yarn-error.log* | |
| package-lock.json | ||
| **/*.bun | ||
| .env | ||
| wrangler.toml | ||
| .wrangler | ||
| .dev.vars | ||
|
|
||
| # build | ||
| .dist | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,34 @@ | ||
| version: "3.9" | ||
|
|
||
| services: | ||
| # Serverless PostgresSQL | ||
| postgres: | ||
| image: "postgres:15.2-alpine" | ||
| restart: always | ||
| container_name: "comuline-db" | ||
| ports: | ||
| - "5432:5432" | ||
| volumes: | ||
| - db:/var/lib/postgresql/data | ||
| env_file: | ||
| - ./.env.db | ||
| pg_proxy: | ||
| image: ghcr.io/neondatabase/wsproxy:latest | ||
| environment: | ||
| APPEND_PORT: "postgres:5432" | ||
| ALLOW_ADDR_REGEX: ".*" | ||
| LOG_TRAFFIC: "true" | ||
| ports: | ||
| - "5433:80" | ||
| depends_on: | ||
| - postgres | ||
|
|
||
| # Serverless Redis | ||
| redis: | ||
| image: redis | ||
| container_name: "comuline-cache" | ||
| ports: | ||
| - "6379:6379" | ||
|
|
||
| volumes: | ||
| db: | ||
| serverless-redis-http: | ||
| ports: | ||
| - "8079:80" | ||
| image: hiett/serverless-redis-http:latest | ||
| env_file: | ||
| - ./.env.db | ||
| depends_on: | ||
| - redis |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,7 @@ | ||
| import type { Config } from "drizzle-kit" | ||
|
|
||
| export default { | ||
| out: "./drizzle/migrations", | ||
| dialect: "postgresql", | ||
| schema: "./src/db/schema", | ||
| out: "./src/db/migrations", | ||
| driver: "pg", | ||
| dbCredentials: { | ||
| connectionString: process.env.DATABASE_URL!, | ||
| }, | ||
| } satisfies Config |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,57 @@ | ||||||||||||||||||||||||||||||||||
| DO $$ BEGIN | ||||||||||||||||||||||||||||||||||
| CREATE TYPE "public"."station_type" AS ENUM('KRL', 'MRT', 'LRT'); | ||||||||||||||||||||||||||||||||||
| EXCEPTION | ||||||||||||||||||||||||||||||||||
| WHEN duplicate_object THEN null; | ||||||||||||||||||||||||||||||||||
| END $$; | ||||||||||||||||||||||||||||||||||
| --> statement-breakpoint | ||||||||||||||||||||||||||||||||||
| CREATE TABLE IF NOT EXISTS "schedule" ( | ||||||||||||||||||||||||||||||||||
| "id" text PRIMARY KEY NOT NULL, | ||||||||||||||||||||||||||||||||||
| "station_id" text NOT NULL, | ||||||||||||||||||||||||||||||||||
| "station_origin_id" text, | ||||||||||||||||||||||||||||||||||
| "station_destination_id" text, | ||||||||||||||||||||||||||||||||||
| "train_id" text NOT NULL, | ||||||||||||||||||||||||||||||||||
| "line" text NOT NULL, | ||||||||||||||||||||||||||||||||||
| "route" text NOT NULL, | ||||||||||||||||||||||||||||||||||
| "time_departure" time NOT NULL, | ||||||||||||||||||||||||||||||||||
| "time_at_destination" time NOT NULL, | ||||||||||||||||||||||||||||||||||
| "metadata" jsonb, | ||||||||||||||||||||||||||||||||||
| "created_at" timestamp with time zone DEFAULT now(), | ||||||||||||||||||||||||||||||||||
| "updated_at" timestamp with time zone DEFAULT now(), | ||||||||||||||||||||||||||||||||||
| CONSTRAINT "schedule_id_unique" UNIQUE("id") | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+7
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment: Use of 'IF NOT EXISTS' in SQL migrations can lead to performance issues Solution: Consider handling migrations in a way that ensures the database schema is in the desired state without relying on 'IF NOT EXISTS'.
Suggested change
|
||||||||||||||||||||||||||||||||||
| --> statement-breakpoint | ||||||||||||||||||||||||||||||||||
| CREATE TABLE IF NOT EXISTS "station" ( | ||||||||||||||||||||||||||||||||||
| "uid" text PRIMARY KEY NOT NULL, | ||||||||||||||||||||||||||||||||||
| "id" text NOT NULL, | ||||||||||||||||||||||||||||||||||
| "name" text NOT NULL, | ||||||||||||||||||||||||||||||||||
| "type" "station_type" NOT NULL, | ||||||||||||||||||||||||||||||||||
| "metadata" jsonb, | ||||||||||||||||||||||||||||||||||
| "created_at" timestamp with time zone DEFAULT now(), | ||||||||||||||||||||||||||||||||||
| "updated_at" timestamp with time zone DEFAULT now(), | ||||||||||||||||||||||||||||||||||
| CONSTRAINT "station_uid_unique" UNIQUE("uid"), | ||||||||||||||||||||||||||||||||||
| CONSTRAINT "station_id_unique" UNIQUE("id") | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
| --> statement-breakpoint | ||||||||||||||||||||||||||||||||||
| DO $$ BEGIN | ||||||||||||||||||||||||||||||||||
| ALTER TABLE "schedule" ADD CONSTRAINT "schedule_station_id_station_id_fk" FOREIGN KEY ("station_id") REFERENCES "public"."station"("id") ON DELETE no action ON UPDATE no action; | ||||||||||||||||||||||||||||||||||
| EXCEPTION | ||||||||||||||||||||||||||||||||||
| WHEN duplicate_object THEN null; | ||||||||||||||||||||||||||||||||||
| END $$; | ||||||||||||||||||||||||||||||||||
| --> statement-breakpoint | ||||||||||||||||||||||||||||||||||
| DO $$ BEGIN | ||||||||||||||||||||||||||||||||||
| ALTER TABLE "schedule" ADD CONSTRAINT "schedule_station_origin_id_station_id_fk" FOREIGN KEY ("station_origin_id") REFERENCES "public"."station"("id") ON DELETE no action ON UPDATE no action; | ||||||||||||||||||||||||||||||||||
| EXCEPTION | ||||||||||||||||||||||||||||||||||
| WHEN duplicate_object THEN null; | ||||||||||||||||||||||||||||||||||
| END $$; | ||||||||||||||||||||||||||||||||||
| --> statement-breakpoint | ||||||||||||||||||||||||||||||||||
| DO $$ BEGIN | ||||||||||||||||||||||||||||||||||
| ALTER TABLE "schedule" ADD CONSTRAINT "schedule_station_destination_id_station_id_fk" FOREIGN KEY ("station_destination_id") REFERENCES "public"."station"("id") ON DELETE no action ON UPDATE no action; | ||||||||||||||||||||||||||||||||||
| EXCEPTION | ||||||||||||||||||||||||||||||||||
| WHEN duplicate_object THEN null; | ||||||||||||||||||||||||||||||||||
| END $$; | ||||||||||||||||||||||||||||||||||
| --> statement-breakpoint | ||||||||||||||||||||||||||||||||||
| CREATE UNIQUE INDEX IF NOT EXISTS "schedule_idx" ON "schedule" USING btree ("id");--> statement-breakpoint | ||||||||||||||||||||||||||||||||||
| CREATE INDEX IF NOT EXISTS "schedule_station_idx" ON "schedule" USING btree ("station_id");--> statement-breakpoint | ||||||||||||||||||||||||||||||||||
| CREATE UNIQUE INDEX IF NOT EXISTS "station_uidx" ON "station" USING btree ("uid");--> statement-breakpoint | ||||||||||||||||||||||||||||||||||
| CREATE INDEX IF NOT EXISTS "station_idx" ON "station" USING btree ("id");--> statement-breakpoint | ||||||||||||||||||||||||||||||||||
| CREATE INDEX IF NOT EXISTS "station_type_idx" ON "station" USING btree ("type"); | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: Hardcoded sensitive information in .dev.example.vars
Solution: Use environment variables or a secure vault service to manage sensitive information instead of hardcoding it in the source code.
!! Make sure the following suggestion is correct before committing it !!