-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
9 changed files
with
134 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,3 @@ | ||
export default async function getBasic() { | ||
return "basic-result" | ||
} |
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,11 @@ | ||
export default async function getError() { | ||
return "should-not-succeed" | ||
} | ||
|
||
export const config = { | ||
api: { | ||
bodyParser: { | ||
sizeLimit: "0kb", | ||
}, | ||
}, | ||
} |
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: ["blitz/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 @@ | ||
module.exports = {} |
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,11 @@ | ||
import {AppProps} from "blitz" | ||
import {ReactQueryDevtools} from "react-query/devtools" | ||
|
||
export default function App({Component, pageProps}: AppProps) { | ||
return ( | ||
<> | ||
<Component {...pageProps} /> | ||
<ReactQueryDevtools /> | ||
</> | ||
) | ||
} |
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 {BlitzScript, Document, DocumentHead, Html, Main} 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,24 @@ | ||
import getError from "app/queries/getError" | ||
import {useQuery} from "blitz" | ||
import {Suspense} from "react" | ||
import {ErrorBoundary} from "react-error-boundary" | ||
|
||
function Content() { | ||
const [result] = useQuery(getError, undefined) | ||
|
||
return <div id="content">{result}</div> | ||
} | ||
|
||
function Page() { | ||
return ( | ||
<div id="page"> | ||
<ErrorBoundary FallbackComponent={() => <div id="error">query failed</div>}> | ||
<Suspense fallback="Loading..."> | ||
<Content /> | ||
</Suspense> | ||
</ErrorBoundary> | ||
</div> | ||
) | ||
} | ||
|
||
export default Page |
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,32 @@ | ||
/* eslint-env jest */ | ||
import {findPort, killApp, launchApp, renderViaHTTP, waitFor} from "lib/blitz-test-utils" | ||
import webdriver from "lib/next-webdriver" | ||
import {join} from "path" | ||
|
||
const context: any = {} | ||
jest.setTimeout(1000 * 60 * 5) | ||
|
||
describe("Misc", () => { | ||
beforeAll(async () => { | ||
context.appPort = await findPort() | ||
context.server = await launchApp(join(__dirname, "../"), context.appPort, { | ||
env: {__NEXT_TEST_WITH_DEVTOOL: 1}, | ||
}) | ||
|
||
const prerender = ["/body-parser"] | ||
await Promise.all(prerender.map((route) => renderViaHTTP(context.appPort, route))) | ||
}) | ||
afterAll(() => killApp(context.server)) | ||
|
||
describe("body parser config", () => { | ||
it("should render query result", async () => { | ||
const browser = await webdriver(context.appPort, "/body-parser") | ||
let text = await browser.elementByCss("#page").text() | ||
expect(text).toMatch(/Loading/) | ||
await browser.waitForElementByCss("#error") | ||
text = await browser.elementByCss("#error").text() | ||
expect(text).toMatch(/query failed/) | ||
if (browser) await browser.close() | ||
}) | ||
}) | ||
}) |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"baseUrl": "./", | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"incremental": true, | ||
"tsBuildInfoFile": ".tsbuildinfo", | ||
"paths": { | ||
"lib/*": ["../../lib/*"] | ||
} | ||
}, | ||
"exclude": ["node_modules"], | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"] | ||
} |