Repository navigation
Expand file tree
/
Copy pathhackkit.config.ts
More file actions
215 lines (202 loc) · 5.72 KB
/
Copy pathhackkit.config.ts
File metadata and controls
215 lines (202 loc) · 5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import { defineHackkitConfig } from "@hackkit/config";
import { CorePermission, type PermissionKey } from "@hackkit/core";
import { databaseOptions } from "./lib/database-config";
import { authOptions } from "./lib/auth-options";
import {
createResendEmailProvider,
createSmtpEmailProvider,
emailNotificationsPlugin,
type EmailProvider,
} from "@hackkit/plugin-notifications-email";
import {
createDiscordHttpRoleSyncProvider,
discordPlugin,
} from "@hackkit/plugin-discord";
import { teamsPlugin, TeamsPermission } from "@hackkit/plugin-teams";
import { env } from "./env";
const participantPermissions = [] as PermissionKey[];
const adminPermissions = [
...Object.values(CorePermission),
...Object.values(TeamsPermission),
] satisfies PermissionKey[];
const shirtSizeOptions = [
{ value: "s", label: "Small" },
{ value: "m", label: "Medium" },
{ value: "l", label: "Large" },
{ value: "xl", label: "Extra large" },
{ value: "2xl", label: "2XL" },
{ value: "3xl", label: "3XL" },
];
const countryOptions = [
{ value: "us", label: "United States" },
{ value: "ca", label: "Canada" },
{ value: "mx", label: "Mexico" },
{ value: "gb", label: "United Kingdom" },
{ value: "other", label: "Other" },
];
const schoolOptions = [
{
value: "University of Texas at San Antonio",
label: "University of Texas at San Antonio",
},
{
value: "University of Texas at Austin",
label: "University of Texas at Austin",
},
{ value: "Texas A&M University", label: "Texas A&M University" },
{ value: "Rice University", label: "Rice University" },
{ value: "other", label: "Other" },
];
const majorOptions = [
{ value: "Computer Science", label: "Computer Science" },
{ value: "Computer Engineering", label: "Computer Engineering" },
{ value: "Electrical Engineering", label: "Electrical Engineering" },
{ value: "Data Science", label: "Data Science" },
{ value: "Design", label: "Design" },
{ value: "Business", label: "Business" },
{ value: "other", label: "Other" },
];
const levelsOfStudy = [
{ value: "Freshman", label: "Freshman" },
{ value: "Sophomore", label: "Sophomore" },
{ value: "Junior", label: "Junior" },
{ value: "Senior", label: "Senior" },
{ value: "Graduate", label: "Graduate" },
{ value: "Recent Grad", label: "Recent Grad" },
{ value: "Other", label: "Other" },
];
const softwareExperienceOptions = [
{ value: "Beginner", label: "Beginner" },
{ value: "Intermediate", label: "Intermediate" },
{ value: "Advanced", label: "Advanced" },
{ value: "Expert", label: "Expert" },
];
const heardFromOptions = [
{ value: "Instagram", label: "Instagram" },
{ value: "Class Presentation", label: "Class presentation" },
{ value: "Twitter", label: "Twitter" },
{ value: "Event Site", label: "Event site" },
{ value: "Friend", label: "Friend" },
{ value: "Other", label: "Other" },
];
const groups = [
{
id: "guild-a",
label: "Guild A",
discordRoleName: "Guild A",
},
{
id: "guild-b",
label: "Guild B",
discordRoleName: "Guild B",
},
{
id: "guild-c",
label: "Guild C",
discordRoleName: "Guild C",
},
] as const;
function createEmailProvider(): EmailProvider | undefined {
if (env.emailProvider === "none") return undefined;
if (env.emailProvider === "resend") {
if (!env.resendApiKey) {
throw new Error(
"RESEND_API_KEY is required when HACKKIT_EMAIL_PROVIDER=resend.",
);
}
return createResendEmailProvider({ apiKey: env.resendApiKey });
}
if (!env.smtpHost) {
throw new Error(
"SMTP_HOST is required when HACKKIT_EMAIL_PROVIDER=smtp.",
);
}
return createSmtpEmailProvider({
host: env.smtpHost,
port: env.smtpPort,
secure: env.smtpSecure,
username: env.smtpUsername,
password: env.smtpPassword,
});
}
function createDiscordRoleSyncProvider() {
if (!env.discordBotApiUrl || !env.discordInternalAuthKey) return undefined;
return createDiscordHttpRoleSyncProvider({
baseUrl: env.discordBotApiUrl,
internalAuthKey: env.discordInternalAuthKey,
});
}
export default defineHackkitConfig({
database: databaseOptions,
auth: authOptions,
defaultCompetitorRoleId: "core.participant",
groups,
seedRoles: [
{
id: "core.participant",
name: "Participant",
position: 10,
permissions: participantPermissions,
},
{
id: "core.owner",
name: "Owner",
position: 0,
permissions: adminPermissions,
},
],
blob:
env.blobAdapter === "s3"
? {
adapter: "s3",
bucket: env.s3Bucket!,
region: env.s3Region!,
endpoint: env.s3Endpoint,
accessKeyId: env.s3AccessKeyId,
secretAccessKey: env.s3SecretAccessKey,
}
: {
adapter: "local",
baseDir: env.localBlobBaseDir,
},
logger: {
level: env.nodeEnv === "production" ? "warn" : "debug",
},
plugins: [
teamsPlugin(),
discordPlugin(() => ({
guildId: env.discordGuildId,
verificationBaseUrl: env.discordVerificationBaseUrl,
participantRole: {
id: env.discordParticipantRoleId,
name: env.discordParticipantRoleName,
},
roleSyncProvider: createDiscordRoleSyncProvider(),
})),
emailNotificationsPlugin(() => ({
provider: createEmailProvider(),
from: env.emailFrom ?? "HackKit <notifications@example.com>",
replyTo: env.emailReplyTo,
appName: "HackKit",
baseUrl: env.appUrl,
})),
],
userDataOptions: {
shirtSize: shirtSizeOptions,
countryOfResidence: countryOptions,
},
hackerRegistrationOptions: {
schools: schoolOptions,
majors: majorOptions,
levelsOfStudy,
softwareExperience: softwareExperienceOptions,
heardFrom: heardFromOptions,
},
eventTypes: [
{ value: "meal", label: "Meal", color: "#FFC107" },
{ value: "workshop", label: "Workshop", color: "#10b981" },
{ value: "ceremony", label: "Ceremony", color: "#9C27B0" },
{ value: "social", label: "Social", color: "#2196F3" },
{ value: "other", label: "Other", color: "#795548" },
],
});