Merge pull request #9 from Tobbe/tobbe-v028-set

RW 0.28 `<Set>`
This commit is contained in:
David Price
2021-03-25 14:19:29 -07:00
committed by GitHub
13 changed files with 1807 additions and 1798 deletions

View File

@@ -11,3 +11,8 @@ DATABASE_URL=file:./dev.db
# disables Prisma CLI update notifier # disables Prisma CLI update notifier
PRISMA_HIDE_UPDATE_MESSAGE=true PRISMA_HIDE_UPDATE_MESSAGE=true
# Option to override the current environment's default api-side log level
# See: https://redwoodjs.com/docs/logger for level options:
# trace | info | debug | warn | error | silent
# LOG_LEVEL=debug

View File

@@ -1,2 +1,3 @@
# DATABASE_URL=file:./dev.db # DATABASE_URL=file:./dev.db
# BINARY_TARGET=native # BINARY_TARGET=native
# LOG_LEVEL=debug

View File

@@ -3,6 +3,6 @@
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@redwoodjs/api": "^0.27.0" "@redwoodjs/api": "^0.28.0"
} }
} }

View File

@@ -3,4 +3,19 @@
import { PrismaClient } from '@prisma/client' import { PrismaClient } from '@prisma/client'
export const db = new PrismaClient() import { emitLogLevels, handlePrismaLogging } from '@redwoodjs/api/logger'
import { logger } from './logger'
/*
* Instance of the Prisma Client
*/
export const db = new PrismaClient({
log: emitLogLevels(['info', 'warn', 'error']),
})
handlePrismaLogging({
db,
logger,
logLevels: ['info', 'warn', 'error'],
})

17
api/src/lib/logger.js Normal file
View File

@@ -0,0 +1,17 @@
import { createLogger } from '@redwoodjs/api/logger'
/**
* Creates a logger with RedwoodLoggerOptions
*
* These extend and override default LoggerOptions,
* can define a destination like a file or other supported pin log transport stream,
* and sets where or not to show the logger configuration settings (defaults to false)
*
* @param RedwoodLoggerOptions
*
* RedwoodLoggerOptions have
* @param {options} LoggerOptions - defines how to log, such as pretty printing, redaction, and format
* @param {string | DestinationStream} destination - defines where to log, such as a transport stream or file
* @param {boolean} showConfig - whether to display logger configuration on initialization
*/
export const logger = createLogger({})

View File

@@ -7,7 +7,7 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@redwoodjs/core": "^0.27.0" "@redwoodjs/core": "^0.28.0"
}, },
"eslintConfig": { "eslintConfig": {
"extends": "@redwoodjs/eslint-config" "extends": "@redwoodjs/eslint-config"

View File

@@ -13,10 +13,10 @@
] ]
}, },
"dependencies": { "dependencies": {
"@redwoodjs/auth": "^0.27.0", "@redwoodjs/auth": "^0.28.0",
"@redwoodjs/forms": "^0.27.0", "@redwoodjs/forms": "^0.28.0",
"@redwoodjs/router": "^0.27.0", "@redwoodjs/router": "^0.28.0",
"@redwoodjs/web": "^0.27.0", "@redwoodjs/web": "^0.28.0",
"netlify-identity-widget": "^1.9.1", "netlify-identity-widget": "^1.9.1",
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"react": "^17.0.1", "react": "^17.0.1",

View File

@@ -7,15 +7,18 @@
// 'src/pages/HomePage/HomePage.js' -> HomePage // 'src/pages/HomePage/HomePage.js' -> HomePage
// 'src/pages/Admin/BooksPage/BooksPage.js' -> AdminBooksPage // 'src/pages/Admin/BooksPage/BooksPage.js' -> AdminBooksPage
import { Router, Route, Private } from '@redwoodjs/router' import { Router, Route, Private, Set } from '@redwoodjs/router'
import BlogLayout from 'src/layouts/BlogLayout'
const Routes = () => { const Routes = () => {
return ( return (
<Router> <Router>
<Route path="/contact" page={ContactPage} name="contact" /> <Set wrap={BlogLayout}>
<Route path="/blog-post/{id:Int}" page={BlogPostPage} name="blogPost" /> <Route path="/contact" page={ContactPage} name="contact" />
<Route path="/about" page={AboutPage} name="about" /> <Route path="/blog-post/{id:Int}" page={BlogPostPage} name="blogPost" />
<Route path="/" page={HomePage} name="home" /> <Route path="/about" page={AboutPage} name="about" />
<Route path="/" page={HomePage} name="home" />
</Set>
<Private unauthenticated="home"> <Private unauthenticated="home">
<Route path="/admin/posts/new" page={NewPostPage} name="newPost" /> <Route path="/admin/posts/new" page={NewPostPage} name="newPost" />
<Route path="/admin/posts/{id:Int}/edit" page={EditPostPage} name="editPost" /> <Route path="/admin/posts/{id:Int}/edit" page={EditPostPage} name="editPost" />

View File

@@ -1,14 +1,11 @@
import { Link, routes } from '@redwoodjs/router' import { Link, routes } from '@redwoodjs/router'
import BlogLayout from 'src/layouts/BlogLayout'
const AboutPage = () => { const AboutPage = () => {
return ( return (
<BlogLayout> <p className="font-light">
<p className="font-light"> This site was created to demonstrate my mastery of Redwood: Look on my
This site was created to demonstrate my mastery of Redwood: Look on my works, ye mighty, and despair!
works, ye mighty, and despair! </p>
</p>
</BlogLayout>
) )
} }

View File

@@ -1,11 +1,8 @@
import BlogLayout from 'src/layouts/BlogLayout'
import BlogPostCell from 'src/components/BlogPostCell' import BlogPostCell from 'src/components/BlogPostCell'
const BlogPostPage = ({ id }) => { const BlogPostPage = ({ id }) => {
return ( return (
<BlogLayout> <BlogPostCell id={id} />
<BlogPostCell id={id} />
</BlogLayout>
) )
} }

View File

@@ -9,7 +9,6 @@ import {
} from '@redwoodjs/forms' } from '@redwoodjs/forms'
import { Flash, useFlash, useMutation } from '@redwoodjs/web' import { Flash, useFlash, useMutation } from '@redwoodjs/web'
import { useForm } from 'react-hook-form' import { useForm } from 'react-hook-form'
import BlogLayout from 'src/layouts/BlogLayout'
const CREATE_CONTACT = gql` const CREATE_CONTACT = gql`
mutation CreateContactMutation($input: CreateContactInput!) { mutation CreateContactMutation($input: CreateContactInput!) {
@@ -38,7 +37,7 @@ const ContactPage = () => {
} }
return ( return (
<BlogLayout> <>
<Flash timeout={1000} className="bg-green-100 text-green-700" /> <Flash timeout={1000} className="bg-green-100 text-green-700" />
<Form <Form
onSubmit={onSubmit} onSubmit={onSubmit}
@@ -106,7 +105,7 @@ const ContactPage = () => {
Save Save
</Submit> </Submit>
</Form> </Form>
</BlogLayout> </>
) )
} }

View File

@@ -1,11 +1,8 @@
import BlogLayout from 'src/layouts/BlogLayout'
import BlogPostsCell from 'src/components/BlogPostsCell' import BlogPostsCell from 'src/components/BlogPostsCell'
const HomePage = () => { const HomePage = () => {
return ( return (
<BlogLayout> <BlogPostsCell />
<BlogPostsCell />
</BlogLayout>
) )
} }

3512
yarn.lock

File diff suppressed because it is too large Load Diff