diff --git a/README.md b/README.md index 656bf4431f..1ef2c711b0 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,11 @@ Framework for building monolithic, full-stack, serverless React apps with zero d The Blitz community is warm, safe, diverse, inclusive, and fun! LGBTQ+, women, and minorities are especially welcome. Please read our [Code of Conduct](https://github.com/blitz-js/blitz/blob/canary/CODE_OF_CONDUCT.md). -## Demo +## LIVE Demo -The initial Blitz demo app is at [examples/first-demo](https://github.com/blitz-js/blitz/blob/canary/examples/first-demo/README.md). NOTE: The API is very alpha, and will change. +The initial Blitz demo is live at [first-demo.blitzjs.com](https://first-demo.blitzjs.com/)! + +It's source code is at [examples/first-demo](https://github.com/blitz-js/blitz/blob/canary/examples/first-demo). NOTE: The API is very alpha, and will change. ## I invite you to join me — let’s build the future of web dev together. 🤝 diff --git a/examples/first-demo/README.md b/examples/first-demo/README.md index 2feebf4b76..18703bcbea 100644 --- a/examples/first-demo/README.md +++ b/examples/first-demo/README.md @@ -1,5 +1,7 @@ # First Blitz Demo +NOTE: The Blitz API is very alpha and will change! This demo is an early prototype + ## Setup - You must have postgres installed and running @@ -11,4 +13,4 @@ ## Production Deployment -WARNING: Production deployment works, but does not work correctly. There's a bug in the unreleased, canary feature Blitz uses. Will update once that's fixed. +This demo is live at [first-demo.blitzjs.com](https://first-demo.blitzjs.com/) diff --git a/examples/first-demo/package.json b/examples/first-demo/package.json index 216c348007..4027b9d8d9 100644 --- a/examples/first-demo/package.json +++ b/examples/first-demo/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@blitzjs/core": "*", - "@prisma/client": "2.0.0-preview022", + "@prisma/client": "2.0.0-alpha.836", "next": "9.2.3-canary.13", "next-transpile-modules": "3.0.2", "react": "16.12.0", @@ -19,9 +19,13 @@ }, "devDependencies": { "@fullhuman/postcss-purgecss": "2.1.0", + "@types/node": "13.7.6", "@types/react": "16.9.23", "autoprefixer": "9.7.4", - "prisma2": "2.0.0-preview022", + "prisma2": "2.0.0-alpha.833", "typescript": "3.8.2" + }, + "browser": { + "@prisma/client": false } } diff --git a/examples/first-demo/pages/index.js b/examples/first-demo/pages/index.js index 18edbbe5c5..35ecf0aa63 100644 --- a/examples/first-demo/pages/index.js +++ b/examples/first-demo/pages/index.js @@ -8,10 +8,25 @@ const Home = props => ( First Blitz Demo +

+ + View on GitHub + +

-
+

First Ever Blitz ⚡️ Demo!

-

Notice the URL bar as you navigate

+

+ This demo is deployed on{' '} + + Zeit + + , as a combo of static pages and serverless functions. +
+
+ It has no client-side data fetching or state management. All data reads & writes are + server-side using Prisma 2. +

View Posts diff --git a/examples/first-demo/pages/posts/[id].tsx b/examples/first-demo/pages/posts/[id].tsx index 9ad2773251..e91c9185af 100644 --- a/examples/first-demo/pages/posts/[id].tsx +++ b/examples/first-demo/pages/posts/[id].tsx @@ -9,6 +9,12 @@ export default Page function Page({post}) { return (

+

+ + View on GitHub + +

+

{post.title}

diff --git a/examples/first-demo/pages/posts/[id]/edit.js b/examples/first-demo/pages/posts/[id]/edit.js index 91134e16df..df34c3faab 100644 --- a/examples/first-demo/pages/posts/[id]/edit.js +++ b/examples/first-demo/pages/posts/[id]/edit.js @@ -9,6 +9,12 @@ export default Page function Page({post}) { return (

+

+ + View on GitHub + +

+

{post.title}

diff --git a/examples/first-demo/pages/posts/index.tsx b/examples/first-demo/pages/posts/index.tsx index 0af542346a..45212f1998 100644 --- a/examples/first-demo/pages/posts/index.tsx +++ b/examples/first-demo/pages/posts/index.tsx @@ -9,6 +9,12 @@ export default Page function Page({posts}) { return (
+

+ + View on GitHub + +

+

{posts.length} Posts

diff --git a/examples/first-demo/pages/posts/new.js b/examples/first-demo/pages/posts/new.js index 5c4a6a5e62..90af622d1a 100644 --- a/examples/first-demo/pages/posts/new.js +++ b/examples/first-demo/pages/posts/new.js @@ -6,6 +6,12 @@ export default Page function Page() { return (

+

+ + View on GitHub + +

+

New Post

diff --git a/examples/first-demo/tsconfig.json b/examples/first-demo/tsconfig.json index 417193f1e4..3862bca741 100644 --- a/examples/first-demo/tsconfig.json +++ b/examples/first-demo/tsconfig.json @@ -1,8 +1,23 @@ { - "extends": "../../tsconfig.json", "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules"], "compilerOptions": { + "target": "es5", + "module": "esnext", + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "rootDir": "../../", + "strict": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "strictPropertyInitialization": true, + "noImplicitThis": true, + "alwaysStrict": true, + "noUnusedLocals": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, @@ -10,7 +25,6 @@ "downlevelIteration": true, "noEmit": true, "esModuleInterop": true, - "module": "esnext", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", diff --git a/packages/core/src/controller.ts b/packages/core/src/controller.ts index 11c9739511..ba03a6cc0a 100644 --- a/packages/core/src/controller.ts +++ b/packages/core/src/controller.ts @@ -9,9 +9,11 @@ export {default as Form} from './components/Form' let db: PrismaClient if (isServer) { - // db = new PrismaClient({log: ['info', 'query']}) - const Client = eval("require('@prisma/client')").PrismaClient - db = new Client({log: ['info', 'query']}) + db = new PrismaClient({log: ['info', 'query']}) + // const Client = eval("require('@prisma/client')").PrismaClient + // db = new Client({log: ['info', 'query']}) + // Go ahead and connect to the DB so that HEAD requests can warm the lambda and db connection + db.connect() } export function Controller(getController: ControllerInput) { @@ -37,7 +39,9 @@ export const harnessController = (Controller: ControllerInstance) => async ( ) => { const startTime = new Date().getTime() console.log('') - console.log(`Started ${req.method} "${req.url}" for ${req.connection.remoteAddress} at ${new Date()}`) + console.log( + `Started ${req.method} "${req.url}" for ${req.socket?.remoteAddress || 'unknown'} at ${new Date()}`, + ) const stringId = req.query && (Array.isArray(req.query.id) ? req.query.id[0] : req.query.id) delete req.query.id @@ -66,6 +70,7 @@ export const harnessController = (Controller: ControllerInstance) => async ( console.log(` Processing by ${Controller.name}.delete`) result = await Controller.delete(params, permit(data, ...Controller.permit)) } else if (req.method === 'HEAD') { + // This is used to warm the lamba before it's actually needed return res.status(204).end() } else { res.status(404) diff --git a/yarn.lock b/yarn.lock index 1513a4e92b..4ebe6348ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2270,10 +2270,10 @@ dependencies: "@types/node" ">= 8" -"@prisma/client@2.0.0-preview022": - version "2.0.0-preview022" - resolved "https://registry.yarnpkg.com/@prisma/client/-/client-2.0.0-preview022.tgz#89c95b2ba17d151edb5891f0a114a2b000ed4e02" - integrity sha512-VVjwodKA7f/xIw704ZP5aAmaVXbcOa0g69E0RWDsMc/mSJlQyBjUtAnQy1QPvjaEA2V8+x+A85zW5JwrIs6qQg== +"@prisma/client@2.0.0-alpha.836": + version "2.0.0-alpha.836" + resolved "https://registry.yarnpkg.com/@prisma/client/-/client-2.0.0-alpha.836.tgz#673c75c0a7a09d8d58f9da38348f59cd3c59a110" + integrity sha512-LRO4dz50M7iPrBJx9N0+IcSeNmniKkQ5BAaj6irYB6TzBMNnv6WwwQ8lzNKvKm0vtPIhuBcd22ZoilZiIUWuhg== "@rollup/plugin-commonjs@^11.0.0": version "11.0.2" @@ -2443,6 +2443,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.4.tgz#76c3cb3a12909510f52e5dc04a6298cdf9504ffd" integrity sha512-oVeL12C6gQS/GAExndigSaLxTrKpQPxewx9bOcwfvJiJge4rr7wNaph4J+ns5hrmIV2as5qxqN8YKthn9qh0jw== +"@types/node@13.7.6": + version "13.7.6" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.6.tgz#cb734a7c191472ae6a2b3a502b4dfffcea974113" + integrity sha512-eyK7MWD0R1HqVTp+PtwRgFeIsemzuj4gBFSQxfPHY5iMjS7474e5wq+VFgTcdpyHeNxyKSaetYAjdMLJlKoWqA== + "@types/parse-json@^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" @@ -10499,6 +10504,11 @@ pretty-quick@2.0.1: mri "^1.1.4" multimatch "^4.0.0" +prisma2@2.0.0-alpha.833: + version "2.0.0-alpha.833" + resolved "https://registry.yarnpkg.com/prisma2/-/prisma2-2.0.0-alpha.833.tgz#f62ac2096efa63a1e7b084c8f7c5bea1c5bb0ec6" + integrity sha512-vO8UDdrcZh60xfU48RbvC/5Y1QsnUwFaY3Q8MRXzNj8ATMQlDwpMNF/QNSLHYEzP8Djb422dU6Agpf/NHgEoRw== + prisma2@2.0.0-preview022: version "2.0.0-preview022" resolved "https://registry.yarnpkg.com/prisma2/-/prisma2-2.0.0-preview022.tgz#959770a89696004411785cfb27a76ebc3eb889aa"