fix: fix warnings

This commit is contained in:
Jonathan Summers-Muir committed 2021-03-15 23:02:51 +08:00
1 parent 867f3d7221
commit ac5de3a89d
5 files changed
+44 -45

No files matched your search

+7 -10
View File
@@ -60,21 +60,18 @@ Authentication only gets you so far. When you need granular authorization rules,
With policies, your database becomes the rules engine. Instead of repetitively filtering your queries, like this ...
<CodeBlock
code={`const loggedInUserId = 'd0714948'
```js
const loggedInUserId = 'd0714948'
let user = await supabase.from('users').select('user_id, name').eq('user_id', loggedInUserId)\n
// Returns { id: 'd0714948', name: 'Jane'
`}
lang="js"
/>
```
... you can simply define a rule on your database table, `auth.uid() = user_id`, and your request will return the rows which pass the rule, even when you remove the filter from your middleware:
<CodeBlock
code={`let user = await supabase.from('users').select('user_id, name')\n
// Still returns { id: 'd0714948', name: 'Jane' }`}
lang="js"
/>
```js
let user = await supabase.from('users').select('user_id, name')\n
// Still returns { id: 'd0714948', name: 'Jane' }
```
### Open source
+22 -24
View File
@@ -30,24 +30,21 @@ We attribute this improvement to community feedback. This has significantly impr
Previously we would throw errors:
<CodeBlock
code={`try {
```js
try {
const { body } = supabase.from('todos').select('*')
} catch (error) {
console.log(error)
}`}
lang="js"
hideCopy
/>
}
```
And now we simply return them:
<CodeBlock
code={`const { data, error } = supabase.from('todos').select('*')
```js
const { data, error } = supabase.from('todos').select('*')
if (error) console.log(error)\n
// else, carry on ..`}
lang="js"
/>
// else, carry on ..
```
After testing this for a while we're very happy with this pattern. Errors are handled next to the offending function. Of course you can always rethrow the error if that's your preference.
@@ -59,23 +56,20 @@ To maintain this philosophy, we created [`gotrue-js`](https://github.com/supabas
Previously:
<CodeBlock
code={`const {
```js
const {
body: { user },
} = await supabase.auth.signup('someone@email.com', 'password')`}
lang="js"
hideCopy
/>
} = await supabase.auth.signup('someone@email.com', 'password')
```
Now:
<CodeBlock
code={`const { user, error } = await supabase.auth.signUp({
```js
const { user, error } = await supabase.auth.signUp({
email: 'someone@email.com',
password: 'password',
})`}
lang="js"
/>
})
```
### Enhancements and fixes
@@ -97,11 +91,15 @@ We've bumped the major version because there are a number of breaking changes. W
Previously:
<CodeBlock code={`const {body} = supabase.from('todos').select('*')`} lang="js" hideCopy />
```js
const { body } = supabase.from('todos').select('*')
```
Now:
<CodeBlock code={`const {data} = supabase.from('todos').select()`} lang="js" />
```js
const { data } = supabase.from('todos').select()
```
### Upgrading
@@ -53,17 +53,15 @@ We reverted our [crypto-js](https://github.com/brix/crypto-js) module from versi
By selectively importing functions from modules like `lodash`, we cut the gzipped size by another 40kb across all our bundles.
<CodeBlock
code={`// before
```js
// before
import _ from 'lodash'\n
// maunally cherry picking modules
import find from 'lodash/find'
import debounce from 'lodash/debounce'\n
// using babel-plugin-lodash
import { find, debounce } from 'lodash'
`}
lang="js"
/>
```
In the above example, we added [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash) to our babel configuration which cherry picks the exact `lodash` functions we import. This makes it easier to import from `lodash` without cluttering the code with selective import statements.
@@ -14,8 +14,6 @@ date: '01-02-2020'
After 10 hectic months of building, Supabase is now in Beta.
<!--truncate-->
### Quick demo
Watch a full demo:
+12 -4
View File
@@ -71,10 +71,18 @@ export async function getStaticProps({ params }: any) {
})
.indexOf(params.slug)
console.log('currentIndex', currentIndex)
console.log('allPosts.length', allPosts.length)
console.log('nextPost', allPosts[currentIndex + 1])
const nextPost = allPosts[currentIndex + 1]
const prevPost = allPosts[currentIndex - 1]
return {
props: {
prevPost: currentIndex === 0 ? null : allPosts[currentIndex - 1],
nextPost: currentIndex === allPosts.length ? null : allPosts[currentIndex + 1],
prevPost: currentIndex === 0 ? null : prevPost ? prevPost : null,
nextPost: currentIndex === allPosts.length ? null : nextPost ? nextPost : null,
relatedPosts,
blog: {
slug: params.slug,
@@ -269,9 +277,9 @@ function BlogPostPage(props: any) {
<div className="grid lg:grid-cols-2 gap-8 py-8">
<div>{props.prevPost && <NextCard post={props.prevPost} label="Last post" />}</div>
<div>
{props.nextPost && (
{/* {props.nextPost && (
<NextCard post={props.nextPost} label="Next post" className="text-right" />
)}
)} */}
</div>
</div>
</div>