The fastest way to make and track predictions.
This repo includes fatebook.io, Fatebook for Slack and Fatebook for Chrome.
You can report bugs in the Issues tab. You can make feature requests there or in our Discord.
- Prisma
- Next.js
- Vercel
- Slack API
- TRPC
- Tailwind
Using the Fatebook API, Fatebook users have created:
- An Obsidian plugin to create and preview Fatebook questions right inside your editor
- An iOS shortcut to create a Fatebook question
- An Alfred workflow to create Fatebook questions
- An Emacs plugin to create Fatebook questions
Share your own API creations in Discord!
If you're interested in contributing, let us know, and we can help you get up and running - thank you!
These following instructions assume you're using macOS and Homebrew.
git clone https://github.com/Sage-Future/fatebook.git
cd fatebook
cp .env.example .env
brew install mkcert
mkcert -install
mkcert localhost
brew install postgresql@15
# Or download and install from https://www.postgresql.org/download
# If you do this, follow the instructions there for starting the database.
# Follow the instructions that the installer provides on how to add postgresql@15 to your PATH.
# For example, on some systems it will tell you to do this:
echo 'export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"' >> ~/.zshrc
. ~/.zshrc
# If you're using Bash rather than Z shell, substitute `~/.bash_profile` for
# `~/.zshrc` in the previous commands.
# Start postgres
LC_ALL="C" /opt/homebrew/opt/postgresql@15/bin/postgres -D /opt/homebrew/var/postgresql@15
Open a new terminal window and run the following commands:
# create `fatebook` role
createuser fatebook
# create `fatebook_development` database, owned by the `fatebook` user
createdb fatebook_development --owner fatebook
- Run
npm install
to install dependencies. - Run
npm run vercel-build
to set up the Fatebook schema.
- Run
npm run dev
. - Go to https://localhost:3000. You should be able to sign in and create predictions.
Run jest tests with npm run test
.
You can also generate a coverage report by running npm run test -- --coverage
, the report will be printed to the console and also saved in the coverage/
directory. The best way to view it is in the html format under coverage/lcov-report/index.html
(run open coverage/lcov-report/index.html
).
There is a launch config for vscode/Cursor called "Next.js: debug fatebook full stack" that will run the web app in the debugger (frontend and backend, breakpoints will work on the client or during SSR).
Fatebook has a Chrome and Firefox extension. The source is in /chrome-extension
To test changes to the Chrome extension:
- Follow the general Fatebook dev setup steps above
- In
after.js
, make sureextensionInfo.isDev = true
npm run dev
, and check that your dev server is running at https://localhost:3000- Go to
chrome://extensions
- Disable the prod Fatebook extension, if you have it installed
- "Load unpacked", and select the chrome-extension directory
- In
chrome://extensions/shortcuts
, set the shortcut for "Make a new prediction" to Cmd-Shift-F, if it's not already set - Before committing, make sure
extensionInfo.isDev = false
inafter.js
If you make a change to the contents of a file in chrome-extension
, to see the changes in your browser you'll need to reload the extension:
- Go to
chrome://extensions
- Click the refresh button next to the unpacked version of Fatebook for Chrome
- Refresh any tabs where you want to test the extension
Changes to Fatebook itself (e.g. changes to /pages/embed/q/[id].tsx
) will be reflected without needing to reload the extension.
Deploying updates to the Chrome extension
Contributors - a maintainer will test and deploy your changes.
Instructions for maintainers:
- Test changes locally in Chrome and Firefox
- Set
extensionInfo.isDev = false
inafter.js
- Deploy any changes to fatebook.io, and test your local unpacked extension with the prod environment
- Increment the
version
field inmanifest.json
- Run
npm run zip
- Upload the Chrome extension to the webstore and the Firefox version to Mozilla addons. Approval normally takes <24 hours
If you want to make or test changes to the Slack integration, you'll need to set up a Slack app. This is more involved - get in touch and we'll help you get up and running.
Optional extra step: Or set up your own Google OAuth credentials
Your .env.example
is prefilled with the shared Fatebook developer Google OAuth credentials. If you'd like to create your own (e.g., to change the configuration), follow these steps:
- Go to https://console.cloud.google.com/apis/credentials.
- Click Configure a project. (Or, if you've previously made a project, click Your project -> New project -> Select your new project)
- Click CREATE CREDENTIALS.
- Select
OAuth client ID
. - You may need to follow the instructions in "Create consent screen" - select all non-sensitive scopes. Then try 3-4 again.
- For
Application type
selectWeb application
. - Under
Name
type something likeFatebook development
. - Under
Authorized redirect URIs
, click ADD URI and underURIs 1
typehttps://localhost:3000/api/auth/callback/google
. - Open the
.env
file in the root of thefatebook
repository. Copy and paste theClient ID
value afterGOOGLE_CLIENT_ID=
infatebook/.env
, and do the same forClient secret
andGOOGLE_CLIENT_SECRET=
.
If you have any problems, let us know!