Skip to content

Commit cbab9be

Browse files
authored
v3 - switch from vercel/nextjs to Cloudflare/tanstack router + query (#10)
1 parent 80b5801 commit cbab9be

File tree

344 files changed

+24228
-12506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

344 files changed

+24228
-12506
lines changed

.env.local.example

Lines changed: 0 additions & 6 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Deploy to Cloudflare
2+
3+
env:
4+
VITE_SUPABASE_URL: ${{secrets.VITE_SUPABASE_URL}}
5+
VITE_SUPABASE_ANON_KEY: ${{secrets.VITE_SUPABASE_ANON_KEY}}
6+
SUPABASE_SERVICE_KEY: ${{secrets.SUPABASE_SERVICE_KEY}}
7+
BOT_MASTODON_ACCESS_TOKEN: ${{secrets.BOT_MASTODON_ACCESS_TOKEN}}
8+
PERSONAL_MASTODON_ACCESS_TOKEN: ${{secrets.PERSONAL_MASTODON_ACCESS_TOKEN}}
9+
CLOUDFLARE_API_TOKEN: ${{secrets.CLOUDFLARE_API_TOKEN}}
10+
11+
on:
12+
push:
13+
branches:
14+
- main
15+
workflow_dispatch:
16+
17+
jobs:
18+
Deploy-Production:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
deployments: write
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: pnpm/action-setup@v4
26+
with:
27+
version: 10.8.0
28+
- name: Install dependencies
29+
run: pnpm install
30+
- name: Build site
31+
run: pnpm build
32+
- name: Deploy to Cloudflare
33+
uses: cloudflare/wrangler-action@v3
34+
with:
35+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
36+
command: pages deploy dist --project-name=otter-web

.gitignore

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,30 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
3-
.env
4-
5-
.cursor/mcp.json
6-
7-
# dependencies
8-
/node_modules
9-
/.pnp
10-
.pnp.js
11-
12-
# testing
13-
/coverage
14-
15-
# next.js
16-
/.next/
17-
/out/
18-
19-
# production
20-
/build
21-
22-
# misc
23-
.DS_Store
24-
*.pem
25-
26-
# debug
1+
# Logs
2+
logs
3+
*.log
274
npm-debug.log*
285
yarn-debug.log*
296
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
3025

31-
# local env files
32-
.env*.local
33-
34-
# vercel
35-
.vercel
26+
# Environment variables
27+
.env
3628

37-
# typescript
38-
*.tsbuildinfo
39-
next-env.d.ts
29+
# cursor
30+
.cursor/

.nvmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 18 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
height="90"
77
/><br/>Otter</h1>
88

9-
> Otter is a self-hosted bookmark manager made with [Next.js](https://nextjs.org) and [Supabase](https://supabase.com) with Mastodon integration.
9+
> Otter is a self-hosted bookmark manager made with React and [Supabase](https://supabase.com) and hosted on [Cloudflare](https://cloudflare.com)
1010
1111
<p>
1212
<a
@@ -55,92 +55,16 @@
5555
### Prerequisites
5656

5757
- [pnpm](https://pnpm.io) - install with `npm i -g pnpm`
58-
- [Vercel](https://vercel.com) account and the [Vercel CLI](https://vercel.com/cli) - install with `npm i -g vercel`
5958
- [Supabase](https://supabase.com) account and the [Supabase CLI](https://supabase.com/docs/reference/cli/introduction) - install with `npm i -g supabase`
6059
- [Cloudflare](https://cloudflare.com) account (optional) - used for the page scraper and Mastodon to Supabase worker
6160

62-
### Setup
63-
64-
1. Fork this repo
65-
2. Go to [database.new](https://database.new) and create a new [Supabase](https://supabase.com) project. You will need the project ID (found in the project settings page) and the the database password for the next step.
66-
3. Link your Supabase project to your local dev environment: `pnpm supabase:link`
67-
4. Seed your database with `pnpm supabase:setup`
68-
5. Install npm dependencies with [pnpm](https://pnpm.io): `pnpm install`
69-
6. Create a new project on vercel and setup env vars (see below)
70-
7. To allow signups, set the value of `ALLOW_SIGNUP` in `./src/constants.ts` to `true`
71-
8. Run the app locally using `pnpm dev`
72-
9. Visit [`http://localhost:5678`](http://localhost:5678) and create an account
73-
74-
### Env vars
75-
76-
Set up the following env vars using either the Vercel CLI or through the Vercel project settings. Once they are added run `vc env pull` to pull them down to your local dev environment.
77-
78-
```bash
79-
# Find these in your Supabase project settings > API
80-
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
81-
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
82-
SUPABASE_SERVICE_KEY=your-service-key # only needed for testing APIs using the `*.rest` files
83-
84-
PERSONAL_MASTODON_ACCESS_TOKEN=your-personal-app-mastodon-access-token
85-
BOT_MASTODON_ACCESS_TOKEN=your-bot-app-mastodon-access-token
86-
OTTER_API_TOKEN=your-otter-api-token
87-
```
88-
89-
### Docs
90-
91-
### API Endpoints
92-
93-
Interactive API docs can be found in the various `*.rest` files in the `/app/api` directory.
94-
95-
- `POST /api/new` - create new item in Otter
96-
- `GET /api/new?url=https://example.com` - quick create new item in Otter. Pass in a `url` query param and it will create a new item with that URL and includes its metadata too
97-
- `GET /api/bookmarks` - returns all bookmarks
98-
<!-- - `GET /api/bookmarks/:id` - returns a single bookmark -->
99-
- `GET /api/search?searchTerm=zander` - search bookmark
100-
- `POST /api/toot` - A PostgreSQL trigger function calls this endpoint anytime a bookmark is created or edited which then creates a new toot on two of my Mastodon accounts ([@otterbot@botsin.space](https://botsin.space/@otterbot) & [@zander@toot.cafe](https://toot.cafe/@zander)). It only sends a toot if the bookmark has the `public` column set to `true`.
101-
102-
### Mastodon integration
103-
104-
Otter has the ability to auto-toot to 2 Mastodon accounts when a new bookmark is created or edited. This is done via a PostgreSQL trigger function that calls the `/api/toot` endpoint.
105-
106-
The trigger function below uses an environment variable in the `Authorization` header to ensure only the owner of the Otter instance can call the endpoint.
107-
108-
```sql
109-
create trigger "toot-otter-items"
110-
after insert
111-
or
112-
update on bookmarks for each row
113-
execute function supabase_functions.http_request (
114-
'https://{your-otter-instance}/api/toot',
115-
'POST',
116-
-- replace {OTTER_API_TOKEN} with your own token
117-
'{"Content-type":"application/json","Authorization":"{OTTER_API_TOKEN}"}',
118-
'{}',
119-
'1000'
120-
);
121-
```
122-
123-
TODO:
124-
125-
- [ ] document the PostgreSQL trigger function that calls the `/api/toot` endpoint
126-
127-
### Bookmarks
128-
129-
#### Adding new bookmark types
130-
131-
1. Add the new type to the types enum `ALTER TYPE type ADD VALUE '???';`
132-
2. Run `pnpm run supabase:types` to update the TypeScript types
133-
3. Add a new `case` to the `TypeToIcon` component
134-
4. Add a new `TypeRadio` component to the `BookmarkForm` component
135-
13661
## Otter ecosystem
13762

13863
I use various other tools to make Otter even better:
13964

14065
- [Raycast extension](https://www.raycast.com/mrmartineau/otter) (on the Raycast extension store)
14166
- [Chrome extension](https://github.com/mrmartineau/otter-extension) (not currently on the Chrome webstore)
14267
- [Apple Shortcut](https://github.com/mrmartineau/Otter/blob/main/public/Add%20to%20Otter.shortcut) - download this shortcut and update your Otter instance URL within it. Then you can add it to your iOS share sheet and quickly add new bookmarks to Otter
143-
- [Page scraper Cloudflare worker](https://github.com/mrmartineau/cloudflare-worker-scraper) used to scrape the metadata of a URL. This is used when adding new bookmarks to Otter
14468
- [Mastodon to Supabase Cloudflare worker](https://github.com/mrmartineau/mastodon-to-supabase) used to backup my Mastodon toots to Supabase
14569

14670
## License

app/(app)/bookmark/[id]/edit/page.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

app/(app)/bookmark/[id]/page.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)