diff --git a/.gitignore b/.gitignore index 304d7dc99..98da9305f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,10 +6,7 @@ .DS_Store .eslintcache .env.local -.env.development.local -.env.test.local -.env.production.local - +.env.*.local npm-debug.log* yarn-debug.log* @@ -24,7 +21,6 @@ tmp node_modules # Build dirs -.env.* .next build dist @@ -89,6 +85,7 @@ docs/docs/reference/core # Next.js docs/docs/reference/nextjs +next-env.d.ts # SvelteKit packages/frameworks-sveltekit/index.* @@ -112,3 +109,6 @@ docs/docs/reference/adapter ## Drizzle migration folder .drizzle + +# Sentry Config File +.sentryclirc diff --git a/README.md b/README.md index afc04cd64..697cb13c7 100644 --- a/README.md +++ b/README.md @@ -67,12 +67,20 @@ For further configuration and usage, refer to [our documentation](https://docs.s This is for you if you want to contribute to the Stack project. +### Requirements + +- Node v20 +- pnpm v9 +- Docker + ### Setup -Make sure you have `pnpm` installed alongside Node v20. Next, ensure you created `.env.local` files by copying `.env` in each sub-package in the `packages` folder and filling out the variables. You will need to start a Postgres database; you can do this with the following command: +Pre-populated .env files for the setup below are available and used by default in `.env.development` in each of the packages, but you can choose to create your own `.env.local` files instead. + +In a terminal, start the dependencies (Postgres and Inbucket) as Docker containers: ```sh -docker run -it --rm -e POSTGRES_PASSWORD=password -p "5432:5432" postgres +docker compose -f dependencies.compose.yaml up ``` Then: @@ -83,15 +91,15 @@ pnpm install # Run code generation (repeat this after eg. changing the Prisma schema) pnpm run codegen -# After starting a Postgres database and filling the corresponding variables in .env.local, push the schema to the database: -# for production databases, use `deploy` instead. See: https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/mental-model#prisma-migrate-in-a-staging-and-production-environment +# Push the most recent Prisma schema to the database pnpm run prisma:server migrate reset - # Start the dev server pnpm run dev ``` +Your IDE may show an error on all `@stackframe/XYZ` imports. To fix this, simply restart the TypeScript language server; for example, in VSCode you can open the command palette (Ctrl+Shift+P) and run `Developer: Reload Window` or `TypeScript: Restart TS server`. + You can also open Prisma Studio to see the database interface and edit data directly: ```sh diff --git a/apps/cjs-test/.env.development b/apps/cjs-test/.env.development new file mode 100644 index 000000000..22fa9f0ce --- /dev/null +++ b/apps/cjs-test/.env.development @@ -0,0 +1,6 @@ +# Contains the credentials for the internal project of Stack's default development environment setup. +# Do not use in a production environment, instead replace it with actual values gathered from https://app.stack-auth.com. +NEXT_PUBLIC_STACK_URL=http://localhost:8101 +NEXT_PUBLIC_STACK_PROJECT_ID=internal +NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only +STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only diff --git a/apps/custom-pages-example/.env.development b/apps/custom-pages-example/.env.development new file mode 100644 index 000000000..22fa9f0ce --- /dev/null +++ b/apps/custom-pages-example/.env.development @@ -0,0 +1,6 @@ +# Contains the credentials for the internal project of Stack's default development environment setup. +# Do not use in a production environment, instead replace it with actual values gathered from https://app.stack-auth.com. +NEXT_PUBLIC_STACK_URL=http://localhost:8101 +NEXT_PUBLIC_STACK_PROJECT_ID=internal +NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only +STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only diff --git a/apps/demo/.env.development b/apps/demo/.env.development new file mode 100644 index 000000000..22fa9f0ce --- /dev/null +++ b/apps/demo/.env.development @@ -0,0 +1,6 @@ +# Contains the credentials for the internal project of Stack's default development environment setup. +# Do not use in a production environment, instead replace it with actual values gathered from https://app.stack-auth.com. +NEXT_PUBLIC_STACK_URL=http://localhost:8101 +NEXT_PUBLIC_STACK_PROJECT_ID=internal +NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only +STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only diff --git a/apps/e2e/.env.development b/apps/e2e/.env.development new file mode 100644 index 000000000..22fa9f0ce --- /dev/null +++ b/apps/e2e/.env.development @@ -0,0 +1,6 @@ +# Contains the credentials for the internal project of Stack's default development environment setup. +# Do not use in a production environment, instead replace it with actual values gathered from https://app.stack-auth.com. +NEXT_PUBLIC_STACK_URL=http://localhost:8101 +NEXT_PUBLIC_STACK_PROJECT_ID=internal +NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only +STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only diff --git a/apps/middleware/.env.development b/apps/middleware/.env.development new file mode 100644 index 000000000..22fa9f0ce --- /dev/null +++ b/apps/middleware/.env.development @@ -0,0 +1,6 @@ +# Contains the credentials for the internal project of Stack's default development environment setup. +# Do not use in a production environment, instead replace it with actual values gathered from https://app.stack-auth.com. +NEXT_PUBLIC_STACK_URL=http://localhost:8101 +NEXT_PUBLIC_STACK_PROJECT_ID=internal +NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only +STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only diff --git a/apps/partial-prerendering/.env.development b/apps/partial-prerendering/.env.development new file mode 100644 index 000000000..22fa9f0ce --- /dev/null +++ b/apps/partial-prerendering/.env.development @@ -0,0 +1,6 @@ +# Contains the credentials for the internal project of Stack's default development environment setup. +# Do not use in a production environment, instead replace it with actual values gathered from https://app.stack-auth.com. +NEXT_PUBLIC_STACK_URL=http://localhost:8101 +NEXT_PUBLIC_STACK_PROJECT_ID=internal +NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only +STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only diff --git a/packages/stack-server/.env b/packages/stack-server/.env index 8f45e37ba..3abf2daf7 100644 --- a/packages/stack-server/.env +++ b/packages/stack-server/.env @@ -3,10 +3,10 @@ NEXT_PUBLIC_STACK_URL=# enter your stack endpoint here, For local development: h NEXT_PUBLIC_STACK_PROJECT_ID=internal NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=# enter your Stack publishable client key here. For local development, just enter a random string, then run `pnpm prisma:server migrate reset` STACK_SECRET_SERVER_KEY=# enter your Stack secret client key here. For local development, do the same as above -SERVER_SECRET=# enter your server secret here. This is used to sign the JWT tokens. Generated using `scripts/generateKey.ts` +SERVER_SECRET=# enter a secret key generated by `scripts/generateKey.ts` here. This is used to sign the JWT tokens. -# OAuth -# These are optional for local development if you don't use OAuth +# OAuth shared keys +# Can be omitted for local development, but shared OAuth keys will not work GITHUB_CLIENT_ID=# client GITHUB_CLIENT_SECRET=# client secret GOOGLE_CLIENT_ID=# client id @@ -33,7 +33,7 @@ DATABASE_CONNECTION_STRING=# enter your connection string here. For local develo DIRECT_DATABASE_CONNECTION_STRING=# enter your direct (unpooled or session mode) database connection string here. For local development: same as above # Misc -STACK_ACCESS_TOKEN_EXPIRATION_TIME=# enter the expiration time for the access token here, optional +STACK_ACCESS_TOKEN_EXPIRATION_TIME=# enter the expiration time for the access token here. Optional, don't specify it for default value NEXT_PUBLIC_STACK_HEAD_TAGS=[{ "tagName": "script", "attributes": {}, "innerHTML": "// insert head tags here" }] NEXT_PUBLIC_DOC_URL=https://docs.stack-auth.com diff --git a/packages/stack-server/.env.development b/packages/stack-server/.env.development new file mode 100644 index 000000000..dfde3e856 --- /dev/null +++ b/packages/stack-server/.env.development @@ -0,0 +1,18 @@ +NEXT_PUBLIC_STACK_URL=http://localhost:8101 +SERVER_SECRET=23-wuNpik0gIW4mruTz25rbIvhuuvZFrLOLtL7J4tyo + +NEXT_PUBLIC_STACK_PROJECT_ID=internal +NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only +STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only + +DATABASE_CONNECTION_STRING=postgres://postgres:password@localhost:5432/stackframe +DIRECT_DATABASE_CONNECTION_STRING=postgres://postgres:password@localhost:5432/stackframe + +NEXT_PUBLIC_DOC_URL=http://localhost:8104 + +EMAIL_HOST=0.0.0.0 +EMAIL_PORT=2500 +EMAIL_SECURE=false +EMAIL_USERNAME=does not matter, ignored by Inbucket +EMAIL_PASSWORD=does not matter, ignored by Inbucket +EMAIL_SENDER=noreply@example.com diff --git a/packages/stack-server/.gitignore b/packages/stack-server/.gitignore index 0ea48f883..fd3dbb571 100644 --- a/packages/stack-server/.gitignore +++ b/packages/stack-server/.gitignore @@ -34,6 +34,3 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts - -# Sentry Config File -.sentryclirc diff --git a/packages/stack-server/prisma/seed.ts b/packages/stack-server/prisma/seed.ts index 6841be50f..06c2d5c72 100644 --- a/packages/stack-server/prisma/seed.ts +++ b/packages/stack-server/prisma/seed.ts @@ -37,7 +37,7 @@ async function seed() { create: { allowLocalhost: true, oauthProviderConfigs: { - create: (['github', 'facebook', 'spotify', 'google', 'microsoft'] as const).map((id) => ({ + create: (['github', 'facebook', 'google', 'microsoft'] as const).map((id) => ({ id, proxiedOAuthConfig: { create: { diff --git a/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/onboarding-dialog.tsx b/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/onboarding-dialog.tsx index 84cbb801b..6250df5a9 100644 --- a/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/onboarding-dialog.tsx +++ b/packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/onboarding-dialog.tsx @@ -45,7 +45,7 @@ export function OnboardingDialog() { >