mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-26 21:26:01 -05:00
Update development setup instructions (#313)
* Add step about requiring patrons.json file * Update steps to get DB up and running * Clarify Discord login setup instructions * Clarify how to start/stop server for new developers * Update README to remove unneeded .env.local var Co-authored-by: Kalle <38327916+Sendouc@users.noreply.github.com>
This commit is contained in:
26
README.md
26
README.md
@@ -44,7 +44,13 @@ With the following steps you can access a few pages that don't need a database.
|
||||
1. Clone the project
|
||||
2. Run `npm i` to install dependencies
|
||||
3. Run `npm run compile` to compile translation files.
|
||||
4. Run `npm run dev` to start the development server at http://localhost:3000/
|
||||
4. Run `npm run dev` to start the development server at http://localhost:3000/. (To stop the server at any time, type `Ctrl+C`.)
|
||||
|
||||
If you do not intend to perform any additional setup steps, you will also need to create an empty list of patrons in `utils/data/patrons.json`:
|
||||
|
||||
```
|
||||
[]
|
||||
```
|
||||
|
||||
### Access rest of the pages
|
||||
|
||||
@@ -59,18 +65,19 @@ DATABASE_URL=postgresql://sendou@localhost:5432
|
||||
_You can see [Prisma's guide on how to set up a PostgreSQL database running locally](https://www.prisma.io/dataguide/postgresql/setting-up-a-local-postgresql-database) for more info._
|
||||
|
||||
6. Use `npm run migrate` to get the database formatted with the right tables.
|
||||
7. Seed some example data in the database by running `npm run seed`. (This seed data is incomplete – see issue #197 if you would like to improve the seed data!)
|
||||
7. Run `npm run prebuild` to generate a few necessary JSON configuration files.
|
||||
8. Seed some example data in the database by running `npm run seed`. (This seed data is incomplete – see issue #197 if you would like to improve the seed data!)
|
||||
|
||||
### Enable logging in
|
||||
|
||||
In addition to the steps above the steps below enable logging in.
|
||||
|
||||
7. Create a file called `.env.local` in the root folder. In it you need following variables:
|
||||
9. Create a file called `.env.local` in the root folder. In it you need following variables:
|
||||
|
||||
```
|
||||
DISCORD_CLIENT_ID=
|
||||
DISCORD_CLIENT_SECRET=
|
||||
JWT_SECRET=
|
||||
DISCORD_CLIENT_ID="<your Discord client ID>"
|
||||
DISCORD_CLIENT_SECRET="<your Discord client secret>"
|
||||
JWT_SECRET="<a long, cryptographically random string>"
|
||||
```
|
||||
|
||||
a) Go to https://discord.com/developers/applications
|
||||
@@ -79,7 +86,12 @@ c) Go to your newly generated application
|
||||
d) On the "General Information" tab both "CLIENT ID" and "CLIENT SECRET" can be found.
|
||||
e) On the "OAuth2" tab add `http://localhost:3000/api/auth/callback/discord` in the list of redirects.
|
||||
|
||||
`JWT_SECRET` can be any randomly generated reasonably long string.
|
||||
For `JWT_SECRET`, use a long, cryptographically random string. You can use `node` to generate such a string as follows:
|
||||
```
|
||||
node -e "require('crypto').randomBytes(64, function(ex, buf) { console.log(buf.toString('base64')) })"
|
||||
```
|
||||
|
||||
Make sure to restart your server after setting these new values (`Ctrl+C` + `npm run dev`).
|
||||
|
||||
## Using API
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ import fs from "fs";
|
||||
import path from "path";
|
||||
import prisma from "../client";
|
||||
|
||||
// Include Prisma's .env file as well, so we can fetch the DATABASE_URL
|
||||
require('dotenv').config({path: 'prisma/.env'});
|
||||
|
||||
const main = async () => {
|
||||
const patrons = await prisma.user.findMany({
|
||||
where: { patreonTier: { not: null } },
|
||||
|
||||
Reference in New Issue
Block a user