This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Showing
52 changed files
with
14,030 additions
and
10 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
Empty file.
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
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 @@ | ||
module.exports = { | ||
presets: ["next/babel"], | ||
plugins: [], | ||
} |
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 @@ | ||
# THIS FILE SHOULD NOT BE CHECKED INTO YOUR VERSION CONTROL SYSTEM | ||
|
||
# You can use this file to specify secrets like your database connection information | ||
# if you move to a more sophisticated database than sqlite. For example, for postgres: | ||
DATABASE_URL=file:./db.sqlite | ||
|
||
# The following env variable is used by prisma-multi-tenant | ||
|
||
MANAGEMENT_URL=file:db/management.db |
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,10 @@ | ||
module.exports = { | ||
extends: ['react-app', 'plugin:jsx-a11y/recommended'], | ||
plugins: ['jsx-a11y'], | ||
rules: { | ||
"import/no-anonymous-default-export": "error", | ||
'import/no-webpack-loader-syntax': 'off', | ||
'react/react-in-jsx-scope': 'off', // React is always in scope with Blitz | ||
'jsx-a11y/anchor-is-valid': 'off', //Doesn't play well with Blitz/Next <Link> usage | ||
}, | ||
} |
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,53 @@ | ||
# dependencies | ||
node_modules | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.pnp.* | ||
.npm | ||
web_modules/ | ||
|
||
# blitz | ||
/.blitz/ | ||
/.next/ | ||
.now | ||
.blitz-console-history | ||
blitz-log.log | ||
|
||
# misc | ||
.DS_Store | ||
|
||
# local env files | ||
.envrc | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Testing | ||
coverage | ||
*.lcov | ||
.nyc_output | ||
lib-cov | ||
|
||
# Caches | ||
*.tsbuildinfo | ||
.eslintcache | ||
.node_repl_history | ||
.yarn-integrity | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test |
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 @@ | ||
save-exact=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 @@ | ||
.gitkeep | ||
.env* | ||
*.ico | ||
*.lock | ||
db/migrations |
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 |
---|---|---|
@@ -1,3 +1,43 @@ | ||
# Blitz example for Prisma-multi-tenant | ||
|
||
TODO | ||
This is an example project to run Blitz with the Prisma-multi-tenant plugin. (See also the tutorial "[Adding multi-tenancy to your Blitz app](/docs/integrations/Blitz.md)") | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install | ||
npm run start | ||
``` | ||
|
||
Go to http://localhost:3000/projects and see the list of projects. | ||
|
||
Then, go to `blitz.config.js`, and change the tenant name to `"prod"`: | ||
|
||
```js | ||
multiTenantMiddleware((req) => { | ||
return "prod" | ||
}) | ||
``` | ||
|
||
Finally, **restart the server** and return see the list of projects at http://localhost:3000/projects | ||
|
||
## Commands you can try | ||
|
||
This will list the available tenants: | ||
|
||
```sh | ||
pmt list # or prisma-multi-tenant list | ||
``` | ||
|
||
This will open studio for the tenants (dev & prod): | ||
|
||
```sh | ||
pmt studio dev | ||
pmt studio prod | ||
``` | ||
|
||
This will make you create a new tenant: | ||
|
||
```sh | ||
pmt new | ||
``` |
Empty file.
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,21 @@ | ||
import React from "react" | ||
|
||
export default class ErrorBoundary extends React.Component<{ | ||
fallback: (error: any) => React.ReactNode | ||
}> { | ||
state = { hasError: false, error: null } | ||
|
||
static getDerivedStateFromError(error: any) { | ||
return { | ||
hasError: true, | ||
error, | ||
} | ||
} | ||
|
||
render() { | ||
if (this.state.hasError) { | ||
return this.props.fallback(this.state.error) | ||
} | ||
return this.props.children | ||
} | ||
} |
Empty file.
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 @@ | ||
import { AppProps } from 'blitz' | ||
|
||
export default function MyApp({ Component, pageProps }: AppProps) { | ||
return <Component {...pageProps} /> | ||
} |
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,23 @@ | ||
import {Document, Html, DocumentHead, Main, BlitzScript /*DocumentContext*/} from 'blitz' | ||
|
||
class MyDocument extends Document { | ||
// Only uncomment if you need to customize this behaviour | ||
// static async getInitialProps(ctx: DocumentContext) { | ||
// const initialProps = await Document.getInitialProps(ctx) | ||
// return {...initialProps} | ||
// } | ||
|
||
render() { | ||
return ( | ||
<Html lang="en"> | ||
<DocumentHead /> | ||
<body> | ||
<Main /> | ||
<BlitzScript /> | ||
</body> | ||
</Html> | ||
) | ||
} | ||
} | ||
|
||
export default MyDocument |
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,197 @@ | ||
import { Head, Link } from "blitz" | ||
|
||
const Home = () => ( | ||
<div className="container"> | ||
<Head> | ||
<title>blitz-app</title> | ||
<link rel="icon" href="/favicon.ico" /> | ||
</Head> | ||
|
||
<main> | ||
<div className="logo"> | ||
<img src="/logo.png" alt="blitz.js" /> | ||
</div> | ||
<p>1. Run this command in your terminal:</p> | ||
<pre> | ||
<code>blitz generate all project name:string</code> | ||
</pre> | ||
<p>2. Then run this command:</p> | ||
<pre> | ||
<code>blitz db migrate</code> | ||
</pre> | ||
|
||
<p> | ||
3. Go to{" "} | ||
<Link href="/projects"> | ||
<a>/projects</a> | ||
</Link> | ||
</p> | ||
<div className="buttons"> | ||
<a | ||
className="button" | ||
href="https://github.com/blitz-js/blitz/blob/master/USER_GUIDE.md?utm_source=blitz-new&utm_medium=app-template&utm_campaign=blitz-new" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Documentation | ||
</a> | ||
<a | ||
className="button-outline" | ||
href="https://github.com/blitz-js/blitz" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Github Repo | ||
</a> | ||
<a | ||
className="button-outline" | ||
href="https://slack.blitzjs.com" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Slack Community | ||
</a> | ||
</div> | ||
</main> | ||
|
||
<footer> | ||
<a | ||
href="https://blitzjs.com?utm_source=blitz-new&utm_medium=app-template&utm_campaign=blitz-new" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Powered by Blitz.js | ||
</a> | ||
</footer> | ||
|
||
<style jsx>{` | ||
.container { | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
main { | ||
padding: 5rem 0; | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
main p { | ||
font-size: 1.2rem; | ||
} | ||
footer { | ||
width: 100%; | ||
height: 60px; | ||
border-top: 1px solid #eaeaea; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: #45009d; | ||
} | ||
footer a { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
footer a { | ||
color: #f4f4f4; | ||
text-decoration: none; | ||
} | ||
.logo { | ||
margin-bottom: 2rem; | ||
} | ||
.logo img { | ||
width: 300px; | ||
} | ||
.buttons { | ||
display: grid; | ||
grid-template-columns: 1fr 1fr 1fr; | ||
grid-gap: 0.5rem; | ||
margin-top: 6rem; | ||
} | ||
a.button { | ||
background-color: #6700eb; | ||
padding: 1rem 2rem; | ||
color: #f4f4f4; | ||
text-align: center; | ||
} | ||
a.button:hover { | ||
background-color: #45009d; | ||
} | ||
a.button-outline { | ||
border: 2px solid #6700eb; | ||
padding: 1rem 2rem; | ||
color: #6700eb; | ||
text-align: center; | ||
} | ||
a.button-outline:hover { | ||
border-color: #45009d; | ||
color: #45009d; | ||
} | ||
pre { | ||
background: #fafafa; | ||
border-radius: 5px; | ||
padding: 0.75rem; | ||
} | ||
code { | ||
font-size: 0.9rem; | ||
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, | ||
Bitstream Vera Sans Mono, Courier New, monospace; | ||
} | ||
.grid { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-wrap: wrap; | ||
max-width: 800px; | ||
margin-top: 3rem; | ||
} | ||
@media (max-width: 600px) { | ||
.grid { | ||
width: 100%; | ||
flex-direction: column; | ||
} | ||
} | ||
`}</style> | ||
|
||
<style jsx global>{` | ||
@import url("https://fonts.googleapis.com/css2?family=Libre+Franklin:wght@300;700&display=swap"); | ||
html, | ||
body { | ||
padding: 0; | ||
margin: 0; | ||
font-family: "Libre Franklin", -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, | ||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; | ||
} | ||
* { | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
box-sizing: border-box; | ||
} | ||
`}</style> | ||
</div> | ||
) | ||
|
||
export default Home |
Oops, something went wrong.