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

v2 api #20

Draft
wants to merge 322 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
322 commits
Select commit Hold shift + click to select a range
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
7c777bd
merge pull request #44 from wanderer-moe/feat/turso-drizzle-migration
dromzeh Sep 3, 2023
943271f
fix duplicate indexes
dromzeh Sep 3, 2023
feec829
update deps, cleanup error msgs
dromzeh Sep 6, 2023
5622074
quickly create an account and log in with your character's credential…
dromzeh Sep 10, 2023
96d35ab
chore: update dependencies
dromzeh Sep 14, 2023
dd7adc1
[skip ci] fix incorrect db on readme
dromzeh Sep 15, 2023
b96d2af
i fucking love drizzle
dromzeh Sep 16, 2023
b01cdec
prettier & limit
dromzeh Sep 16, 2023
5089623
globalize bindings and context types
dromzeh Sep 19, 2023
68cd219
chore: deps
dromzeh Sep 24, 2023
80faab8
ohhh my fucking godddddddddddddddd
dromzeh Sep 25, 2023
854f398
cloudflare KV session storage
dromzeh Sep 25, 2023
cb7dc29
update bindings names
dromzeh Sep 25, 2023
833adf9
feat: discord oauth
dromzeh Sep 25, 2023
6a37c5b
check discord user connection id link
dromzeh Sep 25, 2023
a51e2de
fix discord user transformn
dromzeh Sep 29, 2023
d069bb0
improve discord callback error handling & flow
dromzeh Oct 5, 2023
827a65e
remove session from db schema
dromzeh Oct 8, 2023
4902686
what am i reading
dromzeh Oct 10, 2023
d6ca907
cleanup response codes,; validate oc gen data
dromzeh Oct 10, 2023
70ac3f4
return asset valid and invalid tags on upload
dromzeh Oct 12, 2023
6f42339
prevent users from (un)folowing themselves
dromzeh Oct 12, 2023
d9cd67c
list all unapproved assets
dromzeh Oct 12, 2023
a4d21b2
modifyasset support modiying tags after init ul
dromzeh Oct 12, 2023
3f37973
add displayname + email verif & pw reset table
dromzeh Oct 15, 2023
cacbbd4
fallback to crud for asset querying
dromzeh Oct 15, 2023
15d3ef1
link all routes [scuffed]
dromzeh Oct 15, 2023
6e2e02a
zod formdata validation for required routes
dromzeh Oct 15, 2023
62de25e
??
dromzeh Oct 16, 2023
88aea96
fix formdata parsing
dromzeh Oct 16, 2023
a5ea1ce
lfg
dromzeh Oct 16, 2023
f4f0319
cleanup calling orm
dromzeh Oct 16, 2023
25fc068
create resend wrapper for workers support
dromzeh Oct 16, 2023
b3fe85a
correctly type resend emaildata
dromzeh Oct 16, 2023
c60e617
add db migratation script
dromzeh Oct 17, 2023
21438b4
fix: messy "networking" relation inferring
dromzeh Oct 17, 2023
5a0ed44
maintain consistent plural table names
dromzeh Oct 17, 2023
63e0a93
update deps & fix db indexing
dromzeh Oct 17, 2023
c5f5cd1
consistent timestamp data types
dromzeh Oct 19, 2023
a29b426
fix all relation inferring
dromzeh Oct 19, 2023
b14aef9
update readme, improve drizzle studio config
dromzeh Oct 19, 2023
ba67a49
refactor schema; include [new] `$inferInsert` type
dromzeh Oct 19, 2023
1451b18
convert filenames
dromzeh Oct 19, 2023
9b12ea4
fallback tag to crud
dromzeh Oct 29, 2023
3d9e122
convert assetstatus typing
dromzeh Oct 30, 2023
f8778b7
remove plural asset table name
dromzeh Oct 30, 2023
6c26232
refactor schema, fallback to crud api (#55)
dromzeh Oct 30, 2023
2019d24
`users` => `authUser` & atlas table init
dromzeh Oct 30, 2023
72f6a66
fix relation inferring
dromzeh Oct 30, 2023
637b01f
rewrite resend wrapper to use classes
dromzeh Nov 2, 2023
02f7076
fix asset uploading
dromzeh Nov 2, 2023
4616066
ternary hell (local db fallback)
dromzeh Nov 4, 2023
bab0011
update readme & scripts
dromzeh Nov 5, 2023
f104e4f
test workflow, persistent client & local dev
dromzeh Nov 5, 2023
1a545a2
award for most cursed migration script
dromzeh Nov 5, 2023
ab1ec29
fix key/type mismatch, init local db seed
dromzeh Nov 5, 2023
0d7ee6f
prettier, add seed to test workflow
dromzeh Nov 5, 2023
39986bb
actually commit the workflow changes
dromzeh Nov 5, 2023
f518ec4
seed collections and asset favourites
dromzeh Nov 5, 2023
501d062
replace crypto with uuidv4 for seed
dromzeh Nov 5, 2023
6275808
consistencies... [skip ci]
dromzeh Nov 5, 2023
0eaeabf
initialize managers for asset, game, category, user & tag
dromzeh Nov 5, 2023
3c386d2
update readme & fix ci
dromzeh Nov 5, 2023
413dc5a
utilize for dates
dromzeh Nov 5, 2023
46404c6
asset auto date & cleanup seed
dromzeh Nov 5, 2023
605ee53
init oslo & autofill remaining db cols
dromzeh Nov 6, 2023
5ec307b
test: update node version
dromzeh Nov 6, 2023
2fbb6d4
user collection & favourite manager
dromzeh Nov 6, 2023
989176e
init restructure, swagger/openapi
dromzeh Nov 6, 2023
6588347
fix: prettier
dromzeh Nov 6, 2023
9e95025
parse auth through middleware
dromzeh Nov 6, 2023
6c95461
fix path
dromzeh Nov 6, 2023
f1368c3
going insane (part 1)
dromzeh Nov 10, 2023
57da2aa
refactor current classes
dromzeh Nov 17, 2023
a96755b
what the fuck
dromzeh Nov 17, 2023
b33f913
bro [skip ci]
dromzeh Nov 17, 2023
f060e8d
appropriate int cols use mode bool
dromzeh Nov 17, 2023
8f5a75d
generate new migration
dromzeh Nov 17, 2023
7401a95
chore: update deps
dromzeh Nov 17, 2023
464ac15
we are so fucking back
dromzeh Nov 18, 2023
a355781
link init asset route
dromzeh Nov 18, 2023
417be92
i am going to kill typescript
dromzeh Nov 20, 2023
db49bfb
i am actually stupid
dromzeh Nov 20, 2023
1aa5baf
cleanup db exports bru [skip ci]
dromzeh Nov 20, 2023
87896a3
quote on quote db script refactor
dromzeh Nov 20, 2023
4586123
tagging filter (rawdog sql) LOL
dromzeh Nov 25, 2023
6df505a
update openapi specs & seed script
dromzeh Nov 25, 2023
15ab11a
www
dromzeh Nov 26, 2023
5094109
fix inconsistencies
dromzeh Nov 26, 2023
6837112
migration testing
dromzeh Nov 26, 2023
c0aac68
store username directly into asset table
dromzeh Nov 27, 2023
3e2aad4
init game, category & tag liking tables
dromzeh Nov 29, 2023
68d1828
create new liking managers
dromzeh Nov 29, 2023
10aad41
fix tablename
dromzeh Nov 29, 2023
4550fb2
update deps
dromzeh Dec 8, 2023
eadf0ea
migrate lucia config to v3
dromzeh Dec 8, 2023
850c89f
csrf middleware & set user var
dromzeh Dec 8, 2023
e7f5ad8
[skip ci] replace returned jsonT with json
dromzeh Dec 8, 2023
8481b5e
init new auth route handler
dromzeh Dec 8, 2023
47b84c6
i fucking love typescript
dromzeh Dec 8, 2023
dfee95b
[skip ci] authKey => authCredentials
dromzeh Dec 8, 2023
658a58c
reimpl login w/ password and signup
dromzeh Dec 8, 2023
94c26ca
lfg
dromzeh Dec 8, 2023
ceb7981
auth create init
dromzeh Dec 8, 2023
afa0954
psa: dont log passwords in prod
dromzeh Dec 8, 2023
a4b79f2
refactor time
dromzeh Dec 11, 2023
65748b1
Merge pull request #61 from wanderer-moe/route-restructure
dromzeh Dec 11, 2023
82f2e2f
update authUser properties
dromzeh Dec 13, 2023
70371ae
workflow test
dromzeh Dec 13, 2023
ce30e50
remove unused deps
dromzeh Dec 13, 2023
f7d3332
[no ci] prettier
dromzeh Dec 13, 2023
f413751
handle generations in schema
dromzeh Dec 13, 2023
6c89b39
user collection collaborators schema
dromzeh Dec 16, 2023
b2cba0d
collection collaborators manager
dromzeh Dec 16, 2023
f7f98cc
session logout & return 401
dromzeh Dec 16, 2023
ca8bb50
game create & delete routes
dromzeh Dec 17, 2023
67ceed1
modify game route
dromzeh Dec 17, 2023
8cce32f
[no ci] jesus christ
dromzeh Dec 18, 2023
2bf7240
revert game id oslo gen
dromzeh Dec 18, 2023
fe8fd09
link new contributor route w accounts
dromzeh Dec 18, 2023
0edf368
scalar is fucking awesome
dromzeh Dec 21, 2023
5da111e
export zod schema for tables
dromzeh Dec 21, 2023
83ca680
[no ci] response consistency
dromzeh Dec 21, 2023
ab0c01c
consolidate & spread repetitive responses
dromzeh Dec 21, 2023
e3d70b8
i dont even know what i just wrote
dromzeh Dec 21, 2023
2216ab5
relocate response schema into schema.ts
dromzeh Dec 21, 2023
b058686
create response schemas for game routes
dromzeh Dec 21, 2023
215ba55
fix pk
dromzeh Dec 21, 2023
fdefdb9
gm
dromzeh Dec 31, 2023
f62a5b2
move customcss into openapi config
dromzeh Dec 31, 2023
b98df2f
cleanup deps
dromzeh Dec 31, 2023
4688364
update deps & rlly bad temp fix
dromzeh Dec 31, 2023
2048ac0
revert type defs for db attrs
dromzeh Jan 4, 2024
e7157a8
use built in csrf middleware (im stupid)
dromzeh Jan 4, 2024
870e1d9
rename atlas table to support external file
dromzeh Jan 5, 2024
b87ddcb
set allowedfiletypes and filetype for external files (#71)
dromzeh Jan 5, 2024
9ff8e03
fix validate schema & modify/delete game route
dromzeh Jan 5, 2024
8e492b8
improve request schema validation
dromzeh Jan 5, 2024
16b8715
prettier & fix update asset func
dromzeh Jan 5, 2024
7624f16
favourites validation
dromzeh Jan 5, 2024
681f799
fix tag references
dromzeh Jan 6, 2024
13a3d01
fix auth defs and convert in getuserattr
dromzeh Jan 7, 2024
9761bae
validate session attributes
dromzeh Jan 7, 2024
5434385
invalidate session if attr dont match
dromzeh Jan 7, 2024
00d6537
update .env to .dev.vars (kinda)................................
dromzeh Jan 18, 2024
e606ca4
create .dev.vars in workflow before drizzle init
dromzeh Jan 18, 2024
28e2b30
delete oc related content
dromzeh Jan 21, 2024
e6e9d55
update deps to latest
dromzeh Jan 21, 2024
e4790db
[skip ci] really need cache middleware
dromzeh Jan 22, 2024
91403c8
asset delete and upload route link
dromzeh Jan 22, 2024
856a7a5
asset likes/all/modify - auth fix
dromzeh Jan 22, 2024
1dc2c6d
conv like to POST json instead of GET in path
dromzeh Jan 22, 2024
5a79de1
change modify method to patch, get id in path
dromzeh Jan 22, 2024
c27cff2
change like/unlike to POST in path
dromzeh Jan 22, 2024
0a5ad78
conv game suggestive content int type to bool
dromzeh Jan 23, 2024
83f2514
init collection collaborator roles
dromzeh Jan 23, 2024
3c4dbb4
prettier
dromzeh Jan 23, 2024
0387cd2
update seeded data asset path to be unique
dromzeh Jan 23, 2024
7bec74d
asset modify support changing tags (badly)
dromzeh Jan 23, 2024
8649e31
refactor asset tag handling, use transactions
dromzeh Jan 23, 2024
7a74e06
improve perf with batch api
dromzeh Jan 24, 2024
c1150fd
user follow/unfollow
dromzeh Jan 24, 2024
70fcaf2
view user follows/following
dromzeh Jan 24, 2024
674bae3
remove assetIsOptimized in favour of transform
dromzeh Jan 26, 2024
ab889a1
update deps
dromzeh Jan 28, 2024
18b841c
oh my days
dromzeh Jan 28, 2024
6f39ac4
fix #73 and response cloning
dromzeh Feb 6, 2024
76d35bd
update middleware execution order
dromzeh Feb 6, 2024
24f5666
remove roleflags in favour of role type
dromzeh Feb 6, 2024
83dbe28
request form schema
dromzeh Feb 6, 2024
4adadd3
collection accent colour
dromzeh Feb 6, 2024
64f03f6
request form create/delete route
dromzeh Feb 6, 2024
077198a
update deps
dromzeh Feb 9, 2024
f8dc2ad
update deps
dromzeh Feb 11, 2024
816cee5
request form seeding & view all route
dromzeh Feb 11, 2024
01977ae
rm game manager
dromzeh Mar 12, 2024
8a92705
update deps, remove user/follow manager
dromzeh Mar 12, 2024
c965db7
rm manager for some asset routes
dromzeh Mar 12, 2024
94a79da
fix: lint
dromzeh Mar 12, 2024
2414969
rm assetexternalfiletoasset (#75)
dromzeh Mar 12, 2024
acd1be3
rm asset like manager
dromzeh Mar 12, 2024
1bbbd3c
user block table & relations
dromzeh Mar 13, 2024
231e45a
check block status before follow update
dromzeh Mar 13, 2024
2192431
replace isSupporter with plan, add stripe table
dromzeh Mar 16, 2024
cb6d078
update deps
dromzeh Mar 16, 2024
284713c
asset comment schema
dromzeh Mar 16, 2024
4b3149b
test nested asset comments + impl likes schema
dromzeh Mar 17, 2024
46a397d
upd reference & self nesting fix, new seed data :3
dromzeh Mar 17, 2024
73f87dd
fix incorrect relations
dromzeh Mar 17, 2024
f0e4114
rm american english
dromzeh Mar 17, 2024
f8e48c1
rewrite route structure
dromzeh Mar 17, 2024
242492c
holy fuck
dromzeh Mar 17, 2024
e0d9e02
convert game handler import
dromzeh Mar 17, 2024
4ec3163
fix: handler type
dromzeh Mar 17, 2024
9a3320b
request route impl
dromzeh Mar 17, 2024
96ba39b
fix desc
dromzeh Mar 17, 2024
090856c
remove managers, set asset type to txt over autoincrement int
dromzeh Mar 17, 2024
6a1568c
update user routes
dromzeh Mar 17, 2024
5a1b050
update auth routes
dromzeh Mar 17, 2024
ef1924b
invalidate session via id route
dromzeh Mar 17, 2024
2815656
init collection route files, remove favourites
dromzeh Mar 17, 2024
b6bd6bc
asset comments show likes count
dromzeh Mar 17, 2024
1e9dca1
comment offset and limit, sort by creation date (for now)
dromzeh Mar 17, 2024
8c808b5
fix get single asset schema
dromzeh Mar 17, 2024
18f0647
decrease returned columns for asset search route
dromzeh Mar 17, 2024
f870e28
dl route, add more data for /contributors
dromzeh Mar 17, 2024
57667af
add summary to all openapi routes
dromzeh Mar 17, 2024
d7f12db
tag routes
dromzeh Mar 17, 2024
5809f87
oh
dromzeh Mar 17, 2024
63f191a
category routes impl
dromzeh Mar 17, 2024
235cc18
block/unblock user
dromzeh Mar 17, 2024
e9b8c1c
just one more infinite nesting bro trust me bro
dromzeh Mar 17, 2024
32e0c55
fix comment/replies support
dromzeh Mar 18, 2024
c7be96b
organize routes (rare)
dromzeh Mar 20, 2024
22151a6
allow collection order
dromzeh Mar 20, 2024
d547d7b
ok bro
dromzeh Mar 20, 2024
726d52d
what the fuck
dromzeh Mar 21, 2024
006d36f
upload banner/avatar, rekognition support
dromzeh Mar 21, 2024
6bed840
wagmi
dromzeh Mar 21, 2024
54c4f8b
fix
dromzeh Mar 29, 2024
f8f09d2
bun
dromzeh Apr 1, 2024
7260f4c
readme update
dromzeh Apr 1, 2024
0a8e248
smartest backend dev activities
dromzeh Apr 1, 2024
d96c3e5
so back
dromzeh Apr 4, 2024
b22112e
ok bro
dromzeh Apr 4, 2024
5cdaa89
display session in validation
dromzeh Apr 4, 2024
b3df3a0
add limit to asset query etc
dromzeh Apr 4, 2024
014fa58
?
dromzeh Apr 4, 2024
6ea1be4
search asset support uploader parameter
dromzeh Apr 5, 2024
79e0053
rm real examples from seed data
dromzeh Apr 6, 2024
09cac3f
prettier
dromzeh Apr 6, 2024
431c54d
fix openapi spec, update scalar css
dromzeh May 5, 2024
ac016bf
we are so locked in (trust me)
dromzeh May 5, 2024
3032fa8
shdjgfsfkdhjkldfj;fdgdgkfjbh
dromzeh May 5, 2024
b7033d8
+ modify collection, fix request method
dromzeh May 5, 2024
2ba9959
get collection assets (&inc offset)
dromzeh May 5, 2024
03ce162
collection like/unlike frfr
dromzeh May 5, 2024
651cbc5
asset add/rm 2 collection (probably works)
dromzeh May 6, 2024
43ef7ca
finalize collections(?)
dromzeh May 6, 2024
6ae19ec
lmao
dromzeh May 9, 2024
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
3 changes: 3 additions & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ENVIRONMENT = DEV # DEV | PROD
TURSO_DATABASE_AUTH_TOKEN = adfasdfsdfsdfsdfsdf
TURSO_DATABASE_URL = https://127.0.0.1:8080/
7 changes: 4 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"root": true,
"extends": ["plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["json"],
"plugins": [],
"rules": {
"no-const-assign": "error",
"camelcase": "error",
"no-extra-semi": "error"
"no-extra-semi": "error",
"no-unreachable": "error"
// "sort-imports": "error"
},
"parserOptions": {
"allowImportExportEverywhere": true,
Expand Down
52 changes: 27 additions & 25 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@ jobs:
name: Prettier formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repo
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20.9.0

- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
version: latest
run_install: false
bun-version: latest

- name: Install dependencies
run: pnpm install
run: bun i

- name: Prettier check
run: pnpm run prettier:check
run: bun run prettier:check

lint:
name: ESLint
Expand All @@ -42,21 +41,25 @@ jobs:
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20.9.0

- name: Setup Node.js
uses: oven-sh/setup-bun@v1
with:
node-version: 18
bun-version: latest

- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
version: latest
run_install: false
bun-version: latest

- name: Install dependencies
run: pnpm install
run: bun i

- name: Lint
run: pnpm run lint
run: bun run lint

typecheck:
name: TypeScript types
Expand All @@ -66,18 +69,17 @@ jobs:
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20.9.0

- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
version: latest
run_install: false
bun-version: latest

- name: Install dependencies
run: pnpm install
run: bun i

- name: Lint
run: pnpm run typecheck
run: bun run typecheck
26 changes: 6 additions & 20 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,17 @@ jobs:
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20.9.0

- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
version: latest
run_install: false

# - name: Get pnpm store directory
# id: pnpm-cache
# run: |
# echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

# - uses: actions/cache@v3
# name: Setup pnpm cache
# with:
# path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-
bun-version: latest

- name: Install dependencies
run: pnpm install
run: bun i

- name: Deploy to Cloudflare Workers using Wrangler
uses: cloudflare/wrangler-action@2.0.0
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Run Tests
on:
push:
branches:
- "*"

jobs:
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 5
# local sqld instance for "turso dev"
services:
sqld:
image: ghcr.io/libsql/sqld:latest
ports:
- 8080:8080

env:
ENVIRONMENT: DEV
TURSO_DEV_DATABASE_URL: http://127.0.0.1:8080

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.9.0

- name: Install bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun i

- name: Create .dev.vars file
run: |
echo ENVIRONMENT=$ENVIRONMENT >> .dev.vars
echo TURSO_DEV_DATABASE_URL=$TURSO_DEV_DATABASE_URL >> .dev.vars

- name: Initialize Drizzle
run: bun run drizzle:dev:init
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Wrangler
# webstorm
.idea

# Wrangler & env

.env
.wrangler
.dev.vars

Expand All @@ -11,7 +15,6 @@ npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)

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"

bun run typecheck && bun run lint && bun run prettier:check
2 changes: 2 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"trailingComma": "es5",
"endOfLine": "lf",
"tabWidth": 4,
"semi": false,
"useTabs": false,
"plugins": []
}
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
74 changes: 38 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,77 @@

![Banner]

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

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

</div>

Tech Stack:

- Turso - Database (Libsql, fork of SQLite)
- Drizzle - ORM
- Hono - Framework
- Scalar - OpenAPI Documentation
- Bun - Bun
- Resend - Emails
- Cloudflare R2 - Storage
- Cloudflare DO - Ratelimiting
- Lucia Auth - Authentication

---

## Usage

#### Wrangler
### Bun

Configuration is in `wrangler.toml` - this includes the R2 Bucket and D1 Database.
Bun is relatively lightweight and easy to use. You can install it with `npm i bun -g` globally using `npm`.

- Run `wrangler dev` to preview locally.
- Run `wrangler deploy` to publish to Cloudflare Workers.
### Turso

#### Actions
We use Turso (libsql, very lightweight fork of SQLite) as our database. You will need to install the [Turso CLI](https://docs.turso.tech/reference/turso-cli#installation) then run `turso dev` to start a local database. You can persist data by passing `--db-file <path>`.

- There is a GitHub Action that automatically deploys to Cloudflare Workers on every push to `main` — you can find it in `.github/workflows/deploy.yml`.
The Turso CLI can be run on Windows using WSL and the `--headless` flag.

- If you're using Github Actions, you will have to setup a secret with a Cloudflare API token. You can generate the API token [here][Cloudflare API Token] — use the `Edit Cloudflare Workers` template.
To install `sqld` for dev db `wget https://github.com/libsql/sqld/releases/download/v0.21.9/sqld-installer.sh` or whatever the newest version is, then `sh sqld-installer.sh`.

## API Reference
The API will connect to the local database if the environment is set to `DEV` in `.dev.vars`, else - it will connect to your production database.

### Games
To generate seed data, generate and migrate, you can run `bun run drizzle:init:dev`.

#### Get all games
### Wrangler

```http
GET api.wanderer.moe/games
```
Configuration is in `wrangler.toml`.

#### Get game data
You will most likely require a workers paid plan for authentication and password hashing to work.

```http
GET api.wanderer.moe/game/${gameId}
```
Required environment variables are viewable in `./src/worker-configuration.d.ts`.

| Parameter | Type | Description |
| :-------- | :------- | :---------------------------------- |
| `gameId` | `string` | **Required** — game to get data for |
- Run `wrangler dev` to preview locally.
- Run `wrangler deploy` to publish to Cloudflare Workers.

### Actions

- There is a GitHub Action that automatically deploys to Cloudflare Workers on every push to `main` — you can find it in `.github/workflows/deploy.yml`.

#### Get a game's asset data
- If you're using GitHub Actions, you will have to set up a secret with a Cloudflare API token. You can generate the API token [here][Cloudflare API Token] — use the `Edit Cloudflare Workers` template.

```http
GET api.wanderer.moe/game/${gameId}/${asset}
```
### Database

| Parameter | Type | Description |
| :-------- | :------- | :----------------------------------- |
| `gameId` | `string` | **Required** — game to get data for |
| `asset` | `string` | **Required** — asset to get data for |
- When migrating, you will need `tsx`.
- It's not reccomended to use `drizzle:push` in production. However, there is `drizzle:generate` & `drizzle:migrate` available as scripts.

## Authors

- [@dromzeh][Dromzeh]
- [@dromzeh][dromzeh]

## License

[api.wanderer.moe][api.wanderer.moe] is licensed under the [GNU Affero General Public License v3.0][License] - **You must state all significant changes made to the original software, make the source code available to the public with credit to the original author, original source, and use the same license.**

[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
[dromzeh]: https://github.com/dromzeh
[api.wanderer.moe]: https://api.wanderer.moe
[License]: LICENSE
Binary file added bun.lockb
Binary file not shown.
13 changes: 13 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Config } from "drizzle-kit"

export default {
out: "./src/v2/db/migrations",
schema: "./src/v2/db/schema.ts",
driver: "turso",
breakpoints: true,
strict: true,
verbose: true,
dbCredentials: {
url: "http://127.0.0.1:8080",
},
} satisfies Config
Loading
Loading