diff --git a/.gitignore b/.gitignore index 952a1c8..c127e3c 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ yarn-error.log* # local env files .env*.local .env* +!.env.example # vercel .vercel diff --git a/apps/docs/src/content/docs/guides/dev.mdx b/apps/docs/src/content/docs/guides/dev.mdx index 25da3d4..b15be02 100644 --- a/apps/docs/src/content/docs/guides/dev.mdx +++ b/apps/docs/src/content/docs/guides/dev.mdx @@ -5,30 +5,41 @@ description: Instructions to set up a local development environment for hackclub 1. clone repo 2. `pnpm install` -3. `pnpm dev` -4. `pnpm db:migrate` (RUN THIS AFTER POPULATING BELOW ENV) +3. `cp apps/web/.env.example apps/web/.env && cp packages/db/.env.example packages/db/.env` +4. `pnpm dev` +5. `pnpm db:migrate` (RUN THIS AFTER POPULATING ENV) -- create file at apps/web/.env: +- create file at apps/web/.env (skip if you did step 3): ``` DATABASE_URL=postgresql://postgres:skbiditoilet@localhost:5555/postgres + +# make a slack app here: https://api.slack.com/apps SLACK_NOTIFIER_TOKEN= + # invite your bot to the channel you created. below is #hctv-dev, so use that if you want! NOTIFICATION_CHANNEL_ID=C08M3MGE6PJ + REDIS_URL=redis://localhost:6379 + +# get from https://uploadthing.com/ UPLOADTHING_TOKEN= -# enable oauth mode on your hca account + +# enable oauth mode on your hca account and make an app: https://auth.hackclub.com/identity/edit HCID_CLIENT= HCID_SECRET= # make sure to put this as one of the redirect uri HCID_REDIRECT_URI=http://localhost:3000/auth/hackclub/callback + +# mediamtx settings NEXT_PUBLIC_MEDIAMTX_URL=http://localhost:8891 MEDIAMTX_API=http://localhost:9997 + # idt you should change this MEDIAMTX_PUBLISH_KEY=rjq1xdpCPA4qyt3jge NEXT_PUBLIC_MEDIAMTX_INGEST_ROUTE=localhost:8890 ``` -- create file at packages/db/.env: +- create file at packages/db/.env (skip if you did step 3): ``` DATABASE_URL=postgresql://postgres:skbiditoilet@localhost:5555/postgres DATABASE_DIRECT_URL=postgresql://postgres:skbiditoilet@localhost:5555/postgres diff --git a/apps/web/.env.example b/apps/web/.env.example new file mode 100644 index 0000000..e353b3d --- /dev/null +++ b/apps/web/.env.example @@ -0,0 +1,26 @@ +DATABASE_URL=postgresql://postgres:skbiditoilet@localhost:5555/postgres + +# make a slack app here: https://api.slack.com/apps +SLACK_NOTIFIER_TOKEN= + +# invite your bot to the channel you created. below is #hctv-dev, so use that if you want! +NOTIFICATION_CHANNEL_ID=C08M3MGE6PJ + +REDIS_URL=redis://localhost:6379 + +# get from https://uploadthing.com/ +UPLOADTHING_TOKEN= + +# enable oauth mode on your hca account and make an app: https://auth.hackclub.com/identity/edit +HCID_CLIENT= +HCID_SECRET= +# make sure to put this as one of the redirect uri +HCID_REDIRECT_URI=http://localhost:3000/auth/hackclub/callback + +# mediamtx settings +NEXT_PUBLIC_MEDIAMTX_URL=http://localhost:8891 +MEDIAMTX_API=http://localhost:9997 + +# idt you should change this +MEDIAMTX_PUBLISH_KEY=rjq1xdpCPA4qyt3jge +NEXT_PUBLIC_MEDIAMTX_INGEST_ROUTE=localhost:8890 \ No newline at end of file diff --git a/apps/web/src/app/(ui)/(public)/onboarding/page.client.tsx b/apps/web/src/app/(ui)/(public)/onboarding/page.client.tsx index 729e798..1d6c16a 100644 --- a/apps/web/src/app/(ui)/(public)/onboarding/page.client.tsx +++ b/apps/web/src/app/(ui)/(public)/onboarding/page.client.tsx @@ -107,7 +107,9 @@ export default function OnboardingClient() { name: 'username', label: 'Channel Username', type: 'text', - placeholder: 'e.g., yourname or yourname-codes' + placeholder: 'e.g., yourname or yourname-codes', + maxChars: 20, + inputFilter: /[^a-z0-9_-]/g, }, ]} schemaName="onboard" diff --git a/apps/web/src/components/app/UniversalForm/UniversalForm.tsx b/apps/web/src/components/app/UniversalForm/UniversalForm.tsx index 6e5bb7d..3d4f85e 100644 --- a/apps/web/src/components/app/UniversalForm/UniversalForm.tsx +++ b/apps/web/src/components/app/UniversalForm/UniversalForm.tsx @@ -97,13 +97,21 @@ export function UniversalForm({ {...formField} value={formField.value ?? ''} rows={field.textAreaRows ?? 5} + maxLength={field.maxChars} /> ) : ( { + if (field.inputFilter) { + e.target.value = e.target.value.replace(field.inputFilter, ''); + } + formField.onChange(e); + }} value={formField.value ?? ''} + maxLength={field.maxChars} /> )} diff --git a/apps/web/src/components/app/UniversalForm/types.ts b/apps/web/src/components/app/UniversalForm/types.ts index b547072..7167cd3 100644 --- a/apps/web/src/components/app/UniversalForm/types.ts +++ b/apps/web/src/components/app/UniversalForm/types.ts @@ -12,6 +12,8 @@ export type FormFieldConfig = { value?: any; textArea?: boolean; textAreaRows?: number; + maxChars?: number; + inputFilter?: RegExp; component?: (props: { field: ControllerRenderProps } & any) => React.ReactNode; componentProps?: Record; required?: boolean; diff --git a/packages/db/.env.example b/packages/db/.env.example new file mode 100644 index 0000000..1430954 --- /dev/null +++ b/packages/db/.env.example @@ -0,0 +1,2 @@ +DATABASE_URL=postgresql://postgres:skbiditoilet@localhost:5555/postgres +DATABASE_DIRECT_URL=postgresql://postgres:skbiditoilet@localhost:5555/postgres \ No newline at end of file