Skip to content

Commit 7c24ec9

Browse files
authored
Update CONTRIBUTING.md
1 parent 554547a commit 7c24ec9

File tree

1 file changed

+99
-28
lines changed

1 file changed

+99
-28
lines changed

CONTRIBUTING.md

Lines changed: 99 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,92 @@
22

33
Hello! We're glad to have you interested in contributing to Note Block World. This document will guide you through the process of setting up the project and submitting your contributions.
44

5-
This page is a work-in-progress and will be updated as the project evolves. If you have any questions or need help, feel free to reach out to us on our [Discord server](https://discord.gg/note-block-world-608692895179997252).
5+
This page is a work in progress and will be updated as the project evolves. If you have any questions or need help, feel free to reach out to us on our [Discord server](https://discord.gg/note-block-world-608692895179997252).
66

77
## Stack
88

99
This is a multipackage monorepo managed by [pnpm](https://pnpm.io/), which houses both the backend and frontend of the website. The backend is built with [NestJS](https://nestjs.com/) and the frontend is built with [Next.js](https://nextjs.org/) using server-side rendering (SSR). We use [MongoDB](https://www.mongodb.com/) as our database and [Backblaze B2](https://www.backblaze.com/cloud-storage) for file storage via its S3-compatible API.
1010

11-
## Setting up
11+
## Setting up the project for development
1212

13-
To easily install the project, you can use the [docker-compose.yml](docker-compose.yml) file.
13+
To easily install the project, you can use the [docker-compose-dev.yml](docker-compose-dev.yml) file.
1414

1515
```bash
16-
docker-compose up -d
16+
docker-compose -f docker-compose-dev.yml up -d
1717
```
18+
obs: You can remove the `-d` flag to see the containers' logs.
1819

19-
This will start the backend and frontend servers, as well as a MongoDB instance.
20+
This will start a database container, a maildev container, a minio container, and a minio-client container.
21+
You can check the authentication details in the [docker-compose-dev.yml](docker-compose-dev.yml) file.
2022

21-
---
23+
To configure the env variables, create `.env.development` and `.env.local` files in the [backend](server) and [front-end](web) packages, based on the example files provided. Alternatively, set the environment variables directly in your shell like so:
2224

23-
Alternatively, you can install and use `pnpm` directly:
25+
### backend:
2426

2527
```bash
26-
npm i -g pnpm
27-
pnpm install
28-
```
28+
export NODE_ENV=development
2929

30-
To configure the env variables, create `.env.development` and `.env.local` files in the backend and front-end packages, based on the example files provided. Alternatively, set the environment variables directly in your shell:
30+
export GITHUB_CLIENT_ID=UNSET
31+
export GITHUB_CLIENT_SECRET=UNSET
3132

32-
```bash
33-
export JWT_SECRET="jwtsecret"
34-
export JWT_EXPIRES_IN="1d"
35-
export DB_HOST="localhost:27017"
36-
export DB_PASSWORD="noteblockworldpassword"
37-
export DB_USER="noteblockworlduser"
38-
export SERVER_URL="http://localhost:3000"
33+
export GOOGLE_CLIENT_ID=UNSET
34+
export GOOGLE_CLIENT_SECRET=UNSET
35+
36+
export DISCORD_CLIENT_ID=UNSET
37+
export DISCORD_CLIENT_SECRET=UNSET
38+
39+
export MAGIC_LINK_SECRET=development_magic_link_secret
40+
41+
# in seconds
42+
export COOKIE_EXPIRES_IN=604800 # 1 week
43+
44+
export JWT_SECRET=developmentsecret
45+
export JWT_EXPIRES_IN=1h
46+
47+
export JWT_REFRESH_SECRET=developmentrefreshsecret
48+
export JWT_REFRESH_EXPIRES_IN=7d
49+
50+
export MONGO_URL=mongodb://noteblockworlduser:noteblockworldpassword@localhost:27017/noteblockworld?authSource=admin
51+
52+
export SERVER_URL=http://localhost:4000
53+
export FRONTEND_URL=http://localhost:3000
54+
#APP_DOMAIN=
55+
56+
export RECAPTCHA_KEY=disabled
57+
58+
export S3_ENDPOINT=http://localhost:9000
59+
export S3_BUCKET_SONGS=noteblockworld-songs
60+
export S3_BUCKET_THUMBS=noteblockworld-thumbs
61+
export S3_KEY=minioadmin
62+
export S3_SECRET=minioadmin
63+
export S3_REGION=us-east-1
64+
65+
export WHITELISTED_USERS=
66+
67+
export DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/UNSET
68+
69+
export MAIL_TRANSPORT=smtp://user:pass@localhost:1025
70+
export MAIL_FROM="Example <[email protected]>"
3971
```
4072

41-
You can generate a JWT secret with OpenSSL and replace `jwtsecret` with the output:
73+
Note that for the OAuth providers, you will need to create an application on their respective developer portals and replace `UNSET` , in development, you can use the magic link login method for easy testing.
74+
75+
### frontend:
4276

4377
```bash
44-
openssl rand -hex 64
78+
export THUMBNAIL_URL=localhost:9000
79+
export NEXT_PUBLIC_RECAPTCHA_SITE_KEY="6Le7JNEpAAAAAN7US0WVtz10Mb-IfnTgw-IvEC6s"
80+
export NEXT_PUBLIC_URL=http://localhost:3000
81+
export NEXT_PUBLIC_API_URL=http://localhost:4000/api/v1
4582
```
4683

47-
In Windows, you can use `set` instead of `export`:
4884

49-
```bash
50-
set JWT_SECRET="jwtsecret"
51-
set JWT_EXPIRES_IN="1d"
52-
set DB_HOST="mongodb://localhost:27017/noteblockworld"
53-
set DB_PASSWORD="noteblockworldpassword"
54-
set DB_USER="noteblockworlduser"
55-
set SERVER_URL="http://localhost:3000"
85+
In Windows, you can use `set` instead of `export`.
86+
```cmd
87+
set THUMBNAIL_URL=localhost:9000
88+
set NEXT_PUBLIC_RECAPTCHA_SITE_KEY="6Le7JNEpAAAAAN7US0WVtz10Mb-IfnTgw-IvEC6s"
89+
set NEXT_PUBLIC_URL=http://localhost:3000
90+
set NEXT_PUBLIC_API_URL=http://localhost:4000/api/v1
5691
```
5792

5893
Finally, to run the frontend and backend servers:
@@ -61,4 +96,40 @@ Finally, to run the frontend and backend servers:
6196
pnpm run dev
6297
```
6398

99+
If you only want to run the backend or frontend, you can use the following commands:
100+
101+
```bash
102+
pnpm run dev:server
103+
```
104+
105+
```bash
106+
pnpm run dev:web
107+
```
108+
64109
The backend server will be available at [http://localhost:3000](http://localhost:3000) and the frontend server will be available at [http://localhost:4000](http://localhost:4000).
110+
111+
112+
For populating the database with some test data by sending a post request:
113+
114+
```bash
115+
curl -X 'GET' \
116+
'http://localhost:4000/api/v1/seed/seed-dev' \
117+
-H 'accept: */*'
118+
```
119+
120+
Just so you know, the seed route is only available in development mode.
121+
122+
Currently, tests are only available for the [backend](server), and [shared](shared) packages.
123+
124+
We use [Jest](https://jestjs.io/) for testing. To run the tests, you can use the following command on the package you want to test:
125+
126+
```bash
127+
pnpm test
128+
```
129+
130+
## Code style
131+
132+
We provide a [Prettier](https://prettier.io/) and [ESLint](https://eslint.org/) configuration for the project. You can run the following command to format your code:
133+
```bash
134+
pnpm run lint
135+
```

0 commit comments

Comments
 (0)