Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit 1845bf3

Browse files
committed
Some more fixes i think
1 parent fcfeda3 commit 1845bf3

File tree

11 files changed

+77
-838
lines changed

11 files changed

+77
-838
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ DISCORD_TOKEN=
22
DISCORD_CLIENT_ID=
33
DISCORD_CLIENT_SECRET=
44
DISCORD_REDIRECT_URI=
5-
COOKIE_SECRET=
5+
COOKIE_SECRET=
6+
DATABASE_URL=

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parserOptions": {
3+
"sourceType": "module",
4+
"ecmaVersion": 2023
5+
}
6+
}

.eslintrc.cjs

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

.github/workflows/lint.yml

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

docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ services:
2222
- DISCORD_CLIENT_SECRET=
2323
- DISCORD_REDIRECT_URI=
2424
- COOKIE_SECRET=
25+
- DATABASE_URL=
2526

2627
postgres:
2728
container_name: postgres

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@
88
"dev": "NODE_ENV=development tsx watch src/index.js",
99
"start": "tsx src/server.js",
1010
"reupload": "tsx src/_reupload.js",
11-
"lint": "eslint .",
1211
"preinstall": "npx only-allow yarn"
1312
},
1413
"dependencies": {
14+
"@prisma/client": "^4.11.0",
1515
"cookie-parser": "^1.4.6",
1616
"discord-interactions": "^3.3.0",
1717
"express": "^4.18.2",
1818
"node-fetch": "^3.3.1"
1919
},
2020
"devDependencies": {
21+
"prisma": "^4.11.0",
2122
"dotenv": "16.0.3",
22-
"esbuild": "0.17.11",
23-
"eslint": "8.36.0",
2423
"gray-matter": "4.0.3",
2524
"prettier": "2.8.4"
2625
}

prisma/schema.prisma

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
datasource db {
2+
provider = "postgresql"
3+
url = env("DATABASE_URL")
4+
}
5+
6+
generator client {
7+
provider = "prisma-client-js"
8+
}
9+
10+
model User {
11+
id Int @id @default(autoincrement())
12+
userId Int
13+
token String
14+
}

src/config.js

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

src/register.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,28 @@ const url = `https://discord.com/api/v10/applications/${process.env.DISCORD_CLIE
88
// supported types: number_lt=1, number_gt=2, number_eq=3 number_neq=4, datetime_lt=5, datetime_gt=6, boolean_eq=7, boolean_neq=8
99
const body = [
1010
{
11-
key: 'cookieseaten',
12-
name: 'Cookies Eaten',
13-
description: 'Cookies Eaten Greater Than',
14-
type: 2,
11+
key: 'ispackager',
12+
name: 'Is Packager',
13+
description: 'Is a Prism Packager',
14+
type: 7,
1515
},
1616
{
17-
key: 'allergictonuts',
18-
name: 'Allergic To Nuts',
19-
description: 'Is Allergic To Nuts',
17+
key: 'iscoder',
18+
name: 'Is Coder',
19+
description: 'Is a Prism Code Contributor',
2020
type: 7,
2121
},
2222
{
23-
key: 'bakingsince',
24-
name: 'Baking Since',
25-
description: 'Days since baking their first cookie',
26-
type: 6,
23+
key: 'isdocumentation',
24+
name: 'Is Documentation',
25+
description: 'Is a Prism Documentation Contributor',
26+
type: 7,
27+
},
28+
{
29+
key: 'istranslator',
30+
name: 'Is Translator',
31+
description: 'Is a Prism Translations Contributor',
32+
type: 7,
2733
},
2834
];
2935

src/storage.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
const store = new Map();
1+
import { PrismaClient } from '@prisma/client'
2+
3+
const prisma = new PrismaClient()
24

35
export async function storeDiscordTokens(userId, tokens) {
4-
await store.set(`discord-${userId}`, tokens);
6+
await prisma.user.create({
7+
data: {
8+
id: userId,
9+
token: tokens,
10+
},
11+
})
512
}
613

714
export async function getDiscordTokens(userId) {
8-
return store.get(`discord-${userId}`);
15+
await prisma.user.get({
16+
data: {
17+
id: userId,
18+
},
19+
})
920
}

0 commit comments

Comments
 (0)