diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..1f65bd1390 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners + +* @flybayer diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 65a6c13e5d..37078c4876 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms # github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -# patreon: # Replace with a single Patreon username +patreon: flybayer open_collective: blitzjs -custom: ['https://paypal.me/thebayers?locale.x=en_US'] +custom: ['https://paypal.me/thebayers'] diff --git a/README.md b/README.md index 1ef2c711b0..6960726051 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ The initial Blitz demo is live at [first-demo.blitzjs.com](https://first-demo.bl 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. +## Sponsors + +_Sponsor Blitz and display your logo and hiring status here. [See options on Open Collective](https://opencollective.com/blitzjs)_ + ## I invite you to join me — let’s build the future of web dev together. 🤝 If you’re interested in helping or just want to keep a pulse on the project, [drop your email here 👉 Blitzjs.com](https://blitzjs.com) diff --git a/examples/first-demo/controllers/comments.ts b/examples/first-demo/controllers/comments.ts index 2348ed98ee..145756cebb 100644 --- a/examples/first-demo/controllers/comments.ts +++ b/examples/first-demo/controllers/comments.ts @@ -1,5 +1,5 @@ import {Controller} from '@blitzjs/core' -import alex from 'alex' +import {validContent} from '../utils/contentFilter' export const CommentsController = Controller(({db}) => ({ name: 'CommentsController', @@ -7,8 +7,8 @@ export const CommentsController = Controller(({db}) => ({ permit: ['content'], async create(params, newData) { - if (alex(newData.content).messages.length || newData.content?.toLowerCase().includes('4chan')) { - newData.content = 'Be nice' + if (!validContent(newData.content)) { + newData.content = 'Fruit' } const data = await db.comment.create({ diff --git a/examples/first-demo/controllers/posts.ts b/examples/first-demo/controllers/posts.ts index d04f75001e..fa044b8b20 100644 --- a/examples/first-demo/controllers/posts.ts +++ b/examples/first-demo/controllers/posts.ts @@ -1,5 +1,5 @@ import {Controller} from '@blitzjs/core' -import alex from 'alex' +import {validContent} from '../utils/contentFilter' export const PostsController = Controller(({db}) => ({ name: 'PostsController', @@ -7,7 +7,7 @@ export const PostsController = Controller(({db}) => ({ permit: ['title', 'content'], async index() { - const posts = await db.post.findMany({orderBy: {id: 'asc'}}) + const posts = await db.post.findMany({orderBy: {id: 'desc'}, first: 20}) return { data: {posts}, @@ -23,11 +23,11 @@ export const PostsController = Controller(({db}) => ({ }, async create(params, newData) { - if (alex(newData.title).messages.length || newData.title?.toLowerCase().includes('4chan')) { - newData.title = 'Be nice' + if (!validContent(newData.title)) { + newData.title = 'Fruit' } - if (alex(newData.content).messages.length || newData.content?.toLowerCase().includes('4chan')) { - newData.content = 'Be nice' + if (!validContent(newData.content)) { + newData.content = 'Fruit' } const data = await db.post.create({ @@ -44,11 +44,11 @@ export const PostsController = Controller(({db}) => ({ }, async update(params, newData) { - if (alex(newData.title).messages.length || newData.title?.toLowerCase().includes('4chan')) { - newData.title = 'Be nice' + if (!validContent(newData.title)) { + newData.title = 'Fruit' } - if (alex(newData.content).messages.length || newData.content?.toLowerCase().includes('4chan')) { - newData.content = 'Be nice' + if (!validContent(newData.content)) { + newData.content = 'Fruit' } const data = await db.post.update({ diff --git a/examples/first-demo/pages/posts/[id].tsx b/examples/first-demo/pages/posts/[id].tsx index e91c9185af..5164d3f081 100644 --- a/examples/first-demo/pages/posts/[id].tsx +++ b/examples/first-demo/pages/posts/[id].tsx @@ -63,6 +63,8 @@ function Page({post}) { + +

For your safety, content can only be the name of a fruit

) } diff --git a/examples/first-demo/pages/posts/[id]/edit.js b/examples/first-demo/pages/posts/[id]/edit.js index df34c3faab..43b653ce7f 100644 --- a/examples/first-demo/pages/posts/[id]/edit.js +++ b/examples/first-demo/pages/posts/[id]/edit.js @@ -17,6 +17,8 @@ function Page({post}) {

{post.title}

+

For your safety, content can only be the name of a fruit

+
diff --git a/examples/first-demo/pages/posts/index.tsx b/examples/first-demo/pages/posts/index.tsx index aad477bb80..6b94860a0c 100644 --- a/examples/first-demo/pages/posts/index.tsx +++ b/examples/first-demo/pages/posts/index.tsx @@ -15,7 +15,7 @@ function Page({posts}) {

-

{posts.length} Posts

+

First {posts.length} Posts

Back Home diff --git a/examples/first-demo/pages/posts/new.js b/examples/first-demo/pages/posts/new.js index 90af622d1a..de912b3358 100644 --- a/examples/first-demo/pages/posts/new.js +++ b/examples/first-demo/pages/posts/new.js @@ -14,6 +14,8 @@ function Page() {

New Post

+

For your safety, content can only be the name of a fruit

+
diff --git a/examples/first-demo/utils/contentFilter.ts b/examples/first-demo/utils/contentFilter.ts new file mode 100644 index 0000000000..4ac22ea94b --- /dev/null +++ b/examples/first-demo/utils/contentFilter.ts @@ -0,0 +1,34 @@ +const fruits = [ + 'Apple', + 'Watermelon', + 'Orange', + 'Pear', + 'Cherry', + 'Strawberry', + 'Nectarine', + 'Grape', + 'Mango', + 'Blueberry', + 'Pomegranate', + 'Plum', + 'Banana', + 'Raspberry', + 'Mandarin', + 'Jackfruit', + 'Papaya', + 'Kiwi', + 'Pineapple', + 'Lime', + 'Lemon', + 'Apricot', + 'Grapefruit', + 'Melon', + 'Coconut', + 'Peach', + 'Tomato', +].map(f => f.toLowerCase()) + +export function validContent(str?: string) { + if (!str) return true + return fruits.includes(str.toLowerCase().trim()) +}