diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f2b8f21..a32985f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @sutne \ No newline at end of file +* @sutne diff --git a/.github/workflows/lint-and-format.yaml b/.github/workflows/lint-and-format.yaml index 67295ad..87004f0 100644 --- a/.github/workflows/lint-and-format.yaml +++ b/.github/workflows/lint-and-format.yaml @@ -13,7 +13,8 @@ jobs: - name: Setup Node uses: actions/setup-node@v6 with: - node-version: 22 + node-version: 24 + cache: npm - name: Install Dependencies run: npm ci diff --git a/.gitignore b/.gitignore index 67a07f5..06acb4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .env .DS_Store -.vscode/* -!.vscode/tasks.json +.vscode node_modules .vercel diff --git a/.mise/config.toml b/.mise/config.toml new file mode 100644 index 0000000..bb5f064 --- /dev/null +++ b/.mise/config.toml @@ -0,0 +1,19 @@ +[tools] +node = "24" +python = "3.13" + +[env] +_.file = ".env" + +[task_config] +includes = [ + ".mise/tasks/general.toml", + ".mise/tasks/scripts.toml", + ".mise/tasks/vercel.toml", +] + +[settings] +experimental = true + +[hooks] +postinstall = ["mise run install-dependencies"] diff --git a/.mise/tasks/general.toml b/.mise/tasks/general.toml new file mode 100644 index 0000000..ad2340e --- /dev/null +++ b/.mise/tasks/general.toml @@ -0,0 +1,16 @@ +[install-dependencies] +description = "Install dependencies" +run = ["npm install"] + +[serve] +description = "Serve api with hot reloading on changes" +depends = "install-dependencies" +run = "npx vercel dev" + +[clean] +description = "Remove all untracked or safe to remove files" +run = "git clean -fdx -e .env -e .vercel" + +[format] +description = "Format all files" +run = ["mise fmt", "npm run check"] diff --git a/.mise/tasks/scripts.toml b/.mise/tasks/scripts.toml new file mode 100644 index 0000000..d8f177b --- /dev/null +++ b/.mise/tasks/scripts.toml @@ -0,0 +1,3 @@ +[get-playstation-refresh-token] +description = "Run .ts script to retreive PSN refresh token." +run = "npx ts-node scripts/get_playstation_refresh_token.ts" diff --git a/.mise/tasks/vercel.toml b/.mise/tasks/vercel.toml new file mode 100644 index 0000000..c2d694a --- /dev/null +++ b/.mise/tasks/vercel.toml @@ -0,0 +1,15 @@ +[env-upload] +description = "Upload all local .env variables to Vercel" +run = "python scripts/sync-env.py" + +[env-upload-psn] +description = "Upload local PLAYSTATION_REFRESH_TOKEN from .env to Vercel" +run = "python scripts/sync-env.py PLAYSTATION_REFRESH_TOKEN" + +[env-download] +description = "Download current .env production variables from Vercel" +run = "npx vercel pull --environment=production" + +[deploy] +description = "Deploy current local api to Vercel (also done in ci on push to main)" +run = "npx vercel deploy --prod" diff --git a/.vercelignore b/.vercelignore index d52111b..291a41c 100644 --- a/.vercelignore +++ b/.vercelignore @@ -6,4 +6,4 @@ scripts .prettierrc package-lock.json README.md -temp* \ No newline at end of file +temp* diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 2e96e91..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Install", - "icon": { - "id": "desktop-download", - "color": "terminal.ansiYellow" - }, - "type": "shell", - "command": "npm install" - }, - { - "label": "Develop", - "icon": { - "id": "debug", - "color": "terminal.ansiBlue" - }, - "type": "shell", - "command": "npm start" - }, - { - "label": "Upload '.env'", - "icon": { - "id": "sync", - "color": "terminal.ansiYellow" - }, - "type": "shell", - "command": "python scripts/sync-env.py" - }, - { - "label": "Download '.env'", - "icon": { - "id": "sync", - "color": "terminal.ansiYellow" - }, - "type": "shell", - "command": "npx vercel pull --environment=production" - }, - { - "label": "Run 'get_playtsation-refresh-token.ts'", - "icon": { - "id": "git-fetch", - "color": "terminal.ansiYellow" - }, - "type": "shell", - "command": "npx ts-node scripts/get_playstation_refresh_token.ts" - }, - { - "label": "Upload 'PLAYSTATION_REFRESH_TOKEN'", - "icon": { - "id": "sync", - "color": "terminal.ansiYellow" - }, - "type": "shell", - "command": "python scripts/sync-env.py PLAYSTATION_REFRESH_TOKEN" - }, - { - "label": "Deploy", - "icon": { - "id": "cloud-upload", - "color": "terminal.ansiGreen" - }, - "type": "shell", - "command": "npm run deploy" - }, - { - "label": "Clean", - "icon": { - "id": "trash", - "color": "terminal.ansiRed" - }, - "type": "shell", - "command": "rm -rf node_modules .vercel" - } - ] -} diff --git a/README.md b/README.md index dcfd32f..ced973b 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,37 @@ Some basic endpoints hosted at [vercel][api] that I use for my personal projects. +## Development + +### Configuration + +To setup the dev environment, perform the following: + +1. Install [mise][mise], make sure to also: + - add auto-activation for your shell + - add autocompletion (if it wasn't done automatically) +2. `mise install` +3. `mise run env-download` + 1. When prompted, sign in link this repo to the `personal-api` vercel project. + 2. rename the created: `.vercel/.env.production.local` to `.env` + 3. (optional) remove all variables that don't start with: + - `SPOTIFY_` + - `GITHUB_` + - `PLAYSTATION_` + +### Running + +Once the dev environment is configured, launch the api with: + +```sh +mise serve +``` + +> To show all available commands write `mise run` and hit **tab**. + [on-push-main-action]: https://github.com/sutne/personal-api/actions/workflows/on-push-main.yaml [on-push-main-action-badge]: https://github.com/sutne/personal-api/actions/workflows/on-push-main.yaml/badge.svg -[api]: https://personal-sutne.vercel.app \ No newline at end of file +[api]: https://personal-sutne.vercel.app +[mise]: https://mise.jdx.dev/getting-started.html diff --git a/biome.json b/biome.json index d0187fb..685e16b 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/2.3.8/schema.json", + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", "vcs": { "enabled": true, "clientKind": "git", @@ -29,4 +29,4 @@ "trailingCommas": "all" } } -} \ No newline at end of file +} diff --git a/index.html b/index.html index 4d551b7..b534d59 100644 --- a/index.html +++ b/index.html @@ -72,20 +72,20 @@
Repos: +
Repos: /api/github/repos
- Languages: + Languages: /api/github/languages
- Profile: + Profile: /api/playstation/profile diff --git a/package.json b/package.json index 7f3c534..cb0ac47 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,5 @@ { "scripts": { - "start": "vercel dev", - "deploy": "vercel deploy --prod", "check": "biome check --write --unsafe --diagnostic-level=error", "compile": "tsc --noEmit" },