You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-32Lines changed: 52 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,57 +1,63 @@
1
1
# Cosette Lite
2
2
3
-
This is a full-stack application built using [SvelteKit](https://kit.svelte.dev) and [Fastify](https://www.fastify.io). It was originally made for the verification of the osu! tournament hub discord server.
3
+
**If using an older version of Cosette-lite, please check the migration notes at the bottom.**
4
4
5
-
It is relatively easy to adapt for your own tournament and discord server, with minimum modifications. Some basic knowledge of Typescript, Svelte and Docker may be required to successfully deploy an instance of this projetc.
5
+
This is a full-stack application built using [SvelteKit](https://kit.svelte.dev). It was originally made for the verification of the osu! tournament hub discord server, but is now available as a more universal solution.
6
+
7
+
It is relatively easy to adapt for your own tournament and discord server, with minimum modifications. Some basic knowledge of Typescript, Svelte (and Docker) may be required to successfully deploy an instance of this projetc.
6
8
7
9
Most of the code should be self-explanatory, but if parts aren't feel free to hit me up in the tournament hub Discord, or open an issue here.
8
10
9
11
## Requirements
10
-
-*nix-based OS (macOS, Linux, WSL 2 on Windows) **Native Windows is not supported**
12
+
11
13
- Node.js (LTS, minimum 18.13.0)
12
14
- pnpm (I do not provide support for other package managers, this monorepo **requires** pnpm)
13
15
- Turbo (`pnpm add -g turbo`)
14
16
- Domain name (if deploying to a server)
15
17
- Optionally:
16
-
- Docker
18
+
- Docker
17
19
18
20
## Configuration
19
21
20
22
### Environment
21
23
24
+
### For development
25
+
22
26
Rename `.env.example` to `.env` and fill in the following information:
23
27
24
28
-[Discord account & an OAuth2 application and bot](https://discord.com/developers/applications)
25
29
- Discord OAuth2 Client ID (`PUBLIC_DISCORD_CLIENT_ID`)
- Example of an invite link with the right permissions: https://discord.com/api/oauth2/authorize?client_id=YOURBOTSAPPLICATIONID&permissions=402653185&scope=bot
34
-
-[osu! account & an OAuth2 application](https://osu.ppy.sh/home/account/edit) Scroll down to the "OAuth" section and create your app.
35
-
- Information you need:
36
-
- Client ID (`PUBLIC_OSU2_CLIENT_ID`)
37
-
- Client Secret (`OSU2_CLIENT_SECRET`)
32
+
- Server Member intent must be enabled
33
+
- Required permissions:
34
+
- Manage Roles
35
+
- Manage Nicknames
36
+
- Create Invite
37
+
- Example of an invite link with the right permissions: <https://discord.com/api/oauth2/authorize?client_id=YOURBOTSAPPLICATIONID&permissions=402653185&scope=bot>
38
+
-[osu! account & an OAuth2 application](https://osu.ppy.sh/home/account/edit) Scroll down to the "OAuth" section and create your app.
39
+
- Information you need:
40
+
- Client ID (`PUBLIC_OSU2_CLIENT_ID`)
41
+
- Client Secret (`OSU2_CLIENT_SECRET`)
38
42
39
43
Both these OAuth2 providers will request a callback URL in their forms. When developing locally you will need to add the following callback URLs for Discord and osu! respectively:
40
-
-http://localhost:8000/auth/discord/callback
41
-
-http://localhost:8000/auth/osu/callback
42
44
43
-
If you intend to deploy for usage on a domain (whether it's for development or locally) then you will need to use:
44
-
-https://example.com/auth/discord/callback
45
-
-https://example.com/auth/osu/callback
45
+
-<http://localhost:8000/auth/discord/callback>
46
+
-<http://localhost:8000/auth/osu/callback>
47
+
48
+
If you intend to deploy for usage on a domain (whether it's for development or production) then you will need to use:
49
+
50
+
-<https://example.com/auth/discord/callback>
51
+
-<https://example.com/auth/osu/callback>
46
52
where example.com is your `PUBLIC_BASE_URL`
47
53
48
-
In a production environment it's highly recommended to put this behind a reverse proxy like [nginx](https://nginx.org/en/), [caddy](https://caddyserver.com/), or [traefik](https://traefik.io/). Using these proxies you can easily configure secure connections.
54
+
In a production environment using Docker it's highly recommended to put this behind a reverse proxy like [nginx](https://nginx.org/en/), [caddy](https://caddyserver.com/), or [traefik](https://traefik.io/). Using these proxies you can easily configure secure connections.
49
55
50
56
`COOKIE_SECRET` is the secret you provide for the cookie. Make sure this is something unique and stays consistent when deployed to production. [Refer to this SO post for more information](https://stackoverflow.com/questions/47105436/how-and-when-do-i-generate-a-node-express-cookie-secret)
51
57
52
-
### Customise the stack for your tournament.
58
+
### Customise the stack for your tournament
53
59
54
-
Go to `packages/config/config.ts` and modify the fields accordingly:
60
+
Go to `packages/config/config.ts` and modify the fields accordingly:
55
61
56
62
- Host: the host of the tournament, preferrably their osu! username for clarity. This can also be the owner of the Discord server if this is not a tournament.
57
63
- Name: the name of the tournament or Discord server
@@ -61,14 +67,15 @@ Go to `packages/config/config.ts` and modify the fields accordingly:
61
67
- welcomeChannelId: the channel where the bot can send welcome messages to confirm a successful entry for the user.
62
68
- ownerId: unused.
63
69
- roles: a list of roles you want give to the user in the following format:
70
+
64
71
```json
65
72
{
66
73
"id": "role id from your client",
67
74
"name": "Name of the role"
68
75
}
69
76
```
70
77
71
-
Here's an example of a valid configuration:
78
+
Here's an example of a valid configuration:
72
79
73
80
```ts
74
81
import type { ITournamentConfig } from "./config.interface";
You can also modify the `isUserEligible` function to customise it according to your needs. The function just has to return a boolean for the condition where a user is eligible.
94
101
95
-
The default implementation that we use for verification on the osu! Tournament Hub:
**Note: By default the `OsuUser` in the parameter uses their favourite game mode.**
99
106
100
-
To modify it to use your desired game mode `./apps/webstack/src/routes/auth/osu/callback/+server.ts`[this file](https://github.com/MiraiSubject/cosette-lite/blob/master/apps/webstack/src/routes/auth/osu/callback/%2Bserver.ts) to match the game mode.
107
+
To modify it to use your desired game mode `./apps/webstack/src/routes/auth/osu/callback/+server.ts`[this file](https://github.com/MiraiSubject/cosette-lite/blob/master/apps/webstack/src/routes/auth/osu/callback/%2Bserver.ts) to match the game mode.
101
108
102
109
Currently the valid modes according to the current osu! [API documentation](https://osu.ppy.sh/docs/index.html#gamemode) are:
110
+
103
111
-`fruits` for osu!catch
104
112
-`mania` for osu!mania
105
-
-`osu` forosu!standard
113
+
-`osu` forosu!standard
106
114
-`taiko` for osu!taiko
107
115
108
-
Here is how you would modify the function to get the user's data for the appropriate game mode:
116
+
Here is how you would modify the function to get the user's data for the appropriate game mode:
117
+
109
118
```diff
110
119
async function getUserData(tokens: {
111
120
access_token: string;
@@ -129,28 +138,39 @@ To test production locally do `pnpm build` and then `pnpm start` to start a prod
129
138
130
139
## Deploying to production
131
140
132
-
Convenience scripts are present to build Docker images for both components of the repo (`build-bot.sh` & `build-web.sh`). There is also an example `docker-compose` file present.
141
+
## Self-hosting
142
+
143
+
A convenience script is present to build the Docker image yourself (`build-web.sh`). There is also an example `docker-compose` file present.
133
144
134
-
If you're building on an ARM based system and intend to deploy to an Intel/AMD-based systems you will need to add `--platform linux/amd64` to the build command, for example:
145
+
If you're using an ARM based system and intend to deploy to an Intel/AMD-based systems you will need to add `--platform linux/amd64` to the build command, for example:
to build it for the correct architecture. [Refer to the Docker documentation for more information](https://docs.docker.com/build/building/multi-platform/). Obviously don't use this command if you're already building on an Intel/AMD-based system and intend to deploy on another Intel/AMD-based system.
139
150
151
+
## Migrating from Cosette-Lite 2.1
152
+
153
+
Important migration nodes:
154
+
155
+
- Native Windows works again because we do not use Unix sockets anymore for IPC. In fact there is no IPC at all anymore and it's all contained in one app.
156
+
- Make sure to remove the bot from your `docker-compose.yml` and delete any related images.
157
+
140
158
## Migrating from vue2/nuxt-based oth-verification
141
159
142
160
If you only modified the `config.json` file then all you have to do is move the set configuration to the file in `packages/config/config.ts`.
143
161
144
162
Some important notes regarding the `config.json`:
163
+
145
164
- domains is removed: It's not required anymore for CORS, everything is internalised.
146
165
- dev, https is removed: It's not used anymore.
147
166
148
-
Important migration notes:
167
+
Important migration notes:
168
+
149
169
- pnpm is now the chosen package manager due to the project becoming a monorepo with two components.
150
170
- turborepo (`turbo`) is now a requirement for the same aforementioned reason
151
171
- Native Windows is not supported anymore due to the usage of Unix Sockets for communication between the Discord bot and the web application.
152
172
- Workaround: modify the fastify server to create an http server and point the web application to the same URLs. Make sure to properly configure your firewall and/or secure the endpoints if you're going this route.
153
173
154
174
Any custom modifications made in the Nuxt application will be lost and have to be rewritten using Svelte. Style modifications can easily be migrated if you only lightly modified your instance.
155
175
156
-
If for any reason you'd like to reference the old Nuxt version of this application you can do so [here](https://github.com/MiraiSubject/oth-verification/tree/nuxt-2).
176
+
If for any reason you'd like to reference the old Nuxt version of this application you can do so [here](https://github.com/MiraiSubject/oth-verification/tree/nuxt-2).
0 commit comments