forked from stack-auth/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ced0be7
Showing
225 changed files
with
26,732 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
*.untracked | ||
*.untracked.* | ||
|
||
|
||
# Misc | ||
.DS_Store | ||
.eslintcache | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
firebase-debug.log | ||
ui-debug.log | ||
.pnpm-debug.log | ||
.husky | ||
tmp | ||
|
||
# Dependencies | ||
node_modules | ||
|
||
# Build dirs | ||
.env.* | ||
.next | ||
build | ||
dist | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
**.tsbuildinfo | ||
|
||
.xata* | ||
|
||
# Development app | ||
apps/dev/src/css | ||
apps/dev/prisma/migrations | ||
apps/dev/typeorm | ||
apps/dev/nextjs-2 | ||
|
||
# VS | ||
/.vs/slnx.sqlite-journal | ||
/.vs/slnx.sqlite | ||
/.vs | ||
.vscode/generated* | ||
|
||
# Jetbrains | ||
.idea | ||
|
||
# GitHub Actions runner | ||
/actions-runner | ||
/_work | ||
|
||
# DB | ||
dev.db* | ||
packages/adapter-prisma/prisma/dev.db | ||
packages/adapter-prisma/prisma/migrations | ||
db.sqlite | ||
packages/adapter-supabase/supabase/.branches | ||
packages/adapter-drizzle/.drizzle | ||
|
||
# Tests | ||
coverage | ||
dynamodblocal-bin | ||
firestore-debug.log | ||
test.schema.gql | ||
test-results | ||
playwright-report | ||
blob-report | ||
playwright/.cache | ||
|
||
|
||
# Turborepo | ||
.turbo | ||
|
||
# docusaurus | ||
docs/.docusaurus | ||
docs/manifest.mjs | ||
|
||
# Core | ||
packages/core/src/providers/oauth-types.ts | ||
packages/core/lib | ||
packages/core/providers | ||
docs/docs/reference/core | ||
|
||
# Next.js | ||
docs/docs/reference/nextjs | ||
|
||
# SvelteKit | ||
packages/frameworks-sveltekit/index.* | ||
packages/frameworks-sveltekit/client.* | ||
packages/frameworks-sveltekit/.svelte-kit | ||
packages/frameworks-sveltekit/package | ||
packages/frameworks-sveltekit/vite.config.js.timestamp-* | ||
packages/frameworks-sveltekit/vite.config.ts.timestamp-* | ||
docs/docs/reference/sveltekit | ||
|
||
# SolidStart | ||
docs/docs/reference/solidstart | ||
|
||
|
||
# Express | ||
docs/docs/reference/express | ||
|
||
|
||
# Adapters | ||
docs/docs/reference/adapter | ||
|
||
## Drizzle migration folder | ||
.drizzle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"eslint.workingDirectories": [ | ||
{ | ||
"mode": "auto" | ||
} | ||
], | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"editor.tabSize": 2, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# stack | ||
|
||
## Getting Started | ||
|
||
Make sure you have `pnpm` installed alongside Node v20. Next, ensure you created `.env.local` files by copying `.env` in each of the subpackages 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: | ||
|
||
```sh | ||
docker run -it --rm -e POSTGRES_PASSWORD=password -p "5432:5432" postgres | ||
``` | ||
|
||
Then: | ||
|
||
```sh | ||
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: | ||
pnpm run prisma:server -- db reset | ||
|
||
# Start the dev server | ||
pnpm run dev | ||
``` | ||
|
||
To do linting and typechecking: | ||
|
||
```sh | ||
pnpm run codegen | ||
``` | ||
|
||
You can also open Prisma Studio to see the database interface and edit data directly: | ||
|
||
```sh | ||
pnpm run prisma:server -- studio | ||
``` | ||
|
||
# stack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
NEXT_PUBLIC_STACK_URL=# enter your stack endpoint here, e.g. http://localhost:8101 | ||
NEXT_PUBLIC_STACK_PROJECT_ID=# enter your stack project id here | ||
NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=# enter your stack publishable client key here | ||
STACK_SECRET_SERVER_KEY=# enter your stack secret server key here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
"extends": [ | ||
"../../eslint-configs/defaults.js", | ||
"../../eslint-configs/next.js", | ||
], | ||
"ignorePatterns": ['/*', '!/src'], | ||
rules: { | ||
"import/order": [ | ||
1, | ||
{ | ||
groups: [ | ||
"external", | ||
"builtin", | ||
"internal", | ||
"sibling", | ||
"parent", | ||
"index", | ||
], | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ | ||
dbschema/edgeql-js | ||
|
||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"typescript.tsdk": "../../../node_modules/.pnpm/[email protected]/node_modules/typescript/lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import("next").NextConfig} */ | ||
module.exports = { | ||
webpack(config) { | ||
config.experiments = { ...config.experiments, topLevelAwait: true } | ||
return config | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "dev-app", | ||
"version": "1.0.0", | ||
"description": "", | ||
"private": true, | ||
"scripts": { | ||
"typecheck": "tsc --noEmit", | ||
"clean": "rm -rf .next", | ||
"dev": "next dev --port 8102", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint" | ||
}, | ||
"dependencies": { | ||
"next": "14.0.4", | ||
"next-themes": "^0.2.1", | ||
"react": "^18", | ||
"react-dom": "^18", | ||
"stack": "workspace:*", | ||
"stack-shared": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.23", | ||
"@types/react-dom": "^18.2.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { StackHandler } from "stack"; | ||
import { stackServerApp } from "src/stack"; | ||
|
||
export default function Handler(props) { | ||
return <StackHandler app={stackServerApp} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { StackProvider } from "stack"; | ||
import { stackServerApp } from "src/stack"; | ||
import Provider from "src/components/Provider"; | ||
|
||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode, | ||
}) { | ||
return ( | ||
<html lang="en" suppressHydrationWarning> | ||
<head /> | ||
<body> | ||
<StackProvider | ||
app={stackServerApp} | ||
> | ||
<Provider> | ||
{children} | ||
</Provider> | ||
</StackProvider> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import Link from 'next/link'; | ||
import { stackServerApp } from 'src/stack'; | ||
import ColorModeButton from 'src/components/ColorThemeButton'; | ||
import SignOutButton from 'src/components/SignOutButton'; | ||
import UserInfo from 'src/components/UserInfo'; | ||
import UserInfoClient from 'src/components/UserInfoClient'; | ||
|
||
export default async function Page() { | ||
return ( | ||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}> | ||
<div> | ||
<div>Server:</div> | ||
<UserInfo /> | ||
<div style={{ marginBottom: '1rem' }}/> | ||
<div>Client:</div> | ||
<UserInfoClient /> | ||
</div> | ||
|
||
<div style={{ marginBottom: '1rem' }}/> | ||
<Link href="/handler/signin"> | ||
Sign in | ||
</Link> | ||
<Link href="/handler/signup"> | ||
Sign up | ||
</Link> | ||
<div style={{ marginBottom: '1rem' }}/> | ||
<SignOutButton /> | ||
<Link href={stackServerApp.urls['signOut']}> | ||
Sign out (server) | ||
</Link> | ||
<div style={{ marginBottom: '1rem' }}/> | ||
<ColorModeButton /> | ||
|
||
<div style={{ marginBottom: '1rem' }}/> | ||
<Link href="/protected-client"> | ||
Protected client | ||
</Link> | ||
<Link href="/protected-server"> | ||
Protected server | ||
</Link> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use client'; | ||
import { useUser } from "stack"; | ||
|
||
export default function ProtectedPage() { | ||
useUser({ or: 'redirect' }); | ||
return <div>This is protected. You can see this because you are signed in</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { stackServerApp } from "src/stack"; | ||
|
||
export default async function ProtectedPage() { | ||
await stackServerApp.getUser({ or: 'redirect' }); | ||
return <div>This is protected. You can see this because you are signed in</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-disable @typescript-eslint/no-misused-promises */ | ||
'use client'; | ||
import { useStackApp, validateEmail } from "stack"; | ||
import { useState } from "react"; | ||
|
||
export default function CustomCredentialSignIn() { | ||
const [email, setEmail] = useState(''); | ||
const [password, setPassword] = useState(''); | ||
const [error, setError] = useState(''); | ||
const app = useStackApp(); | ||
|
||
const onSubmit = async () => { | ||
if (!validateEmail(email)) { | ||
setError('Please enter a valid email'); | ||
return; | ||
} | ||
if (!password) { | ||
setError('Please enter your password'); | ||
return; | ||
} | ||
const errorCode = await app.signInWithCredential({ email, password, redirectUrl: app.urls.userHome }); | ||
// It is better to handle each error code separately, but for simplicity, we will just show the error code directly | ||
if (errorCode) { | ||
setError(errorCode); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
{error} | ||
<input type='email' placeholder="[email protected]" value={email} onChange={(e) => setEmail(e.target.value)} /> | ||
<input type='password' placeholder="password" value={password} onChange={(e) => setPassword(e.target.value)} /> | ||
<button onClick={onSubmit}>Sign In</button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* eslint-disable @typescript-eslint/no-misused-promises */ | ||
'use client'; | ||
import { useStackApp } from "stack"; | ||
|
||
export default function CustomOAuthSignIn() { | ||
const app = useStackApp(); | ||
|
||
return <div> | ||
<h1>My Custom Sign In page</h1> | ||
<button onClick={async () => await app.signInWithOauth('google')}>Sign In with Google</button> | ||
</div>; | ||
} |
Oops, something went wrong.