Skip to content
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

migrate from planetscale [& raw sql] -> turso & drizzle #44

Merged
merged 33 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7d2e2bb
upd lucia to sqlite, begin migration to drizzle
dromzeh Aug 23, 2023
9fa92a6
remove semis, upd deps, upload asset route
dromzeh Aug 24, 2023
aed77d9
user upload avatar & update self assignable roles
dromzeh Aug 24, 2023
b89fec0
response promises & check for file type
dromzeh Aug 24, 2023
83798ee
upload banner route
dromzeh Aug 24, 2023
89937aa
update const routes to funcs
dromzeh Aug 24, 2023
f049f82
upd deps tempfix bindings csrf protection
dromzeh Aug 30, 2023
554fccc
export defined context for correct types in routes
dromzeh Aug 30, 2023
18110f9
feat: view & save oc generator responses 👀👀
dromzeh Aug 31, 2023
2738427
cleanup unused files
dromzeh Aug 31, 2023
19c9b28
delete old banner/avatar and rewrite on upload
dromzeh Aug 31, 2023
2b7dbb5
move everything into `/v2/` route
dromzeh Aug 31, 2023
045c346
del saved oc gen res, better session invalidation
dromzeh Sep 1, 2023
e2154f2
i hate writing schemas
dromzeh Sep 1, 2023
ee10594
questionable `/search/all` endpoint, update routes
dromzeh Sep 1, 2023
d46f742
upd prettier, asset modify & approve
dromzeh Sep 1, 2023
0a3d4ec
iter 1 multiple tags search
dromzeh Sep 1, 2023
2ce2642
asset filtering in a single db query ty drizzle
dromzeh Sep 2, 2023
0f57f23
i dont want to see a schema ever again
dromzeh Sep 2, 2023
c39db5f
search recent assets endpoint [returns 100]
dromzeh Sep 2, 2023
5caa0c3
user relations
dromzeh Sep 2, 2023
d8c2900
help
dromzeh Sep 2, 2023
37e29eb
switch assetstatus to int
dromzeh Sep 2, 2023
d82a4ea
yay
dromzeh Sep 2, 2023
fcf8a75
refactor
dromzeh Sep 2, 2023
248959e
xcvmbnxcvsdfkj
dromzeh Sep 2, 2023
17f3e3d
mfw im about to sleep and my brain starts working
dromzeh Sep 2, 2023
c2d6b0a
fuck yeah asset collections lets g 💯💯💯💯💯💯💯
dromzeh Sep 2, 2023
68d3d33
asset validity checks
dromzeh Sep 3, 2023
2e85d43
show hidden saves if user is querying own account
dromzeh Sep 3, 2023
04fbe7a
my brain is going to explode
dromzeh Sep 3, 2023
08b520c
wrong operator 😭😭😭
dromzeh Sep 3, 2023
b12f452
all tags endpoint
dromzeh Sep 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"root": true,
"extends": ["plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["json"],
"rules": {
"no-const-assign": "error",
"camelcase": "off",
"no-extra-semi": "error"
},
"parserOptions": {
"allowImportExportEverywhere": true,
"ecmaVersion": 2020,
"ecmaFeatures": {
"impliedStrict": true
},
"sourceType": "module"
}
"root": true,
"extends": ["plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["json"],
"rules": {
"no-const-assign": "error",
"camelcase": "off",
"no-extra-semi": "error"
},
"parserOptions": {
"allowImportExportEverywhere": true,
"ecmaVersion": 2020,
"ecmaFeatures": {
"impliedStrict": true
},
"sourceType": "module"
}
}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# webstorm
.idea

# Wrangler
# Wrangler & env

.env
.wrangler
.dev.vars

# temp
src/routes/check.ts
scripts/

# Logs

Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm run typecheck && pnpm run lint && pnpm run prettier:check
14 changes: 8 additions & 6 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"bracketSameLine": true,
"singleQuote": false,
"trailingComma": "es5",
"endOfLine": "lf",
"tabWidth": 4,
"plugins": []
"bracketSameLine": true,
"singleQuote": false,
"trailingComma": "es5",
"endOfLine": "lf",
"tabWidth": 4,
"semi": false,
"useTabs": true,
"plugins": []
}
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

![Banner]

![Quality] ![API Response] ![CDN Response]
![Quality]

Source code for the API powering [**wanderer.moe**](https://wanderer.moe) — using **Cloudflare Workers** and **Hono** with **R2 Storage** for the CDN, and **Planetscale** for the Database.
Source code for the API powering [**wanderer.moe**](https://wanderer.moe) — using **Cloudflare Workers** and **Hono** with **R2 Storage** for the CDN, **Turso** and **Drizzle** for the Database.

</div>

Expand Down Expand Up @@ -40,8 +40,6 @@ You will need to setup environment variables for the Discord Bot Token for `/con
[Banner]: https://files.catbox.moe/qa3eus.svg
[API Status]: https://status.wanderer.moe/history/api
[CDN Status]: https://status.wanderer.moe/history/cdn
[API Response]: https://img.shields.io/endpoint?label=API%20Response&style=for-the-badge&url=https%3A%2F%2Fraw.githubusercontent.com%2Fwanderer-moe%2Fstatus%2FHEAD%2Fapi%2Fapi%2Fresponse-time.json
[CDN Response]: https://img.shields.io/endpoint?label=CDN%20Response&style=for-the-badge&url=https%3A%2F%2Fraw.githubusercontent.com%2Fwanderer-moe%2Fstatus%2FHEAD%2Fapi%2Fcdn%2Fresponse-time.json
[Quality]: https://img.shields.io/codefactor/grade/github/wanderer-moe/api?label=quality&style=for-the-badge
[Cloudflare API Token]: https://dash.cloudflare.com/profile/api-tokens
[Dromzeh]: https://github.com/dromzeh
Expand Down
28 changes: 14 additions & 14 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import "dotenv/config";

import type { Config } from "drizzle-kit";
import "dotenv/config"
const { TURSO_DATABASE_AUTH_TOKEN, TURSO_DATABASE_URL } = process.env
import type { Config } from "drizzle-kit"

export default {
out: "./src/db/migrations",
schema: "./src/db/schema.ts",
breakpoints: true,
driver: "mysql2",
dbCredentials: {
host: process.env.DATABASE_HOST || "",
user: process.env.DATABASE_USERNAME || "",
password: process.env.DATABASE_PASSWORD || "",
database: "planetscale",
},
} satisfies Config;
out: "./src/v2/db/migrations",
schema: "./src/v2/db/schema.ts",
driver: "turso",
breakpoints: true,
strict: true,
verbose: true,
dbCredentials: {
url: TURSO_DATABASE_URL as string,
authToken: TURSO_DATABASE_AUTH_TOKEN as string,
},
} satisfies Config
76 changes: 37 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
{
"name": "wanderer-moe-api",
"version": "1.0.1b",
"scripts": {
"prettier:fmt": "prettier --write .",
"dev": "wrangler dev --remote",
"publish": "wrangler publish --minify",
"lint": "eslint . --ext .ts",
"prettier:check": "prettier --check .",
"typecheck": "tsc --noEmit",
"prisma:generate": "npx prisma generate --accelerate",
"prisma:push": "npx prisma db push"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20230807.0",
"@types/node": "^20.4.8",
"eslint": "^8.46.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-json": "^3.1.0",
"typescript": "^5.1.6",
"wrangler": "3.4.0"
},
"private": true,
"dependencies": {
"@aws-sdk/client-s3": "^3.386.0",
"@lucia-auth/adapter-mysql": "^2.0.0",
"@lucia-auth/adapter-prisma": "^3.0.1",
"@planetscale/database": "^1.10.0",
"@prisma/client": "^5.1.1",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"dotenv": "^16.3.1",
"drizzle-kit": "^0.19.12",
"drizzle-orm": "^0.28.1",
"hono": "^3.4.1",
"lucia": "^2.2.0",
"mysql2": "^3.6.0",
"prettier": "^3.0.1",
"render2": "^1.2.1",
"resend": "^0.17.2"
}
"name": "wanderer-moe-api",
"version": "1.0.1b",
"scripts": {
"prettier:fmt": "prettier --write .",
"dev": "wrangler dev --remote",
"publish": "wrangler publish --minify",
"lint": "eslint . --ext .ts",
"prettier:check": "prettier --check .",
"typecheck": "tsc --noEmit",
"drizzle:generate": "drizzle-kit generate:sqlite",
"drizzle:push": "drizzle-kit push:sqlite"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20230821.0",
"@types/node": "^20.5.8",
"dotenv": "^16.3.1",
"drizzle-kit": "^0.19.13",
"eslint": "^8.48.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-json": "^3.1.0",
"husky": "^8.0.3",
"tsx": "^3.12.8",
"typescript": "^5.2.2",
"wrangler": "3.6.0"
},
"private": true,
"dependencies": {
"@libsql/client": "^0.3.2",
"@lucia-auth/adapter-sqlite": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"drizzle-orm": "^0.28.5",
"hono": "^3.5.6",
"lucia": "^2.4.1",
"mysql2": "^3.6.0",
"prettier": "^3.0.3",
"resend": "^1.0.0"
}
}
Loading