- fork the repo https://github.com/tudorilisoi/blitz-e4
git cloneyour fork on to your machinegit add remote origin https://github.com/tudorilisoi/blitz-e4- install node v18.18.0, then run
npm i -g yarn - run
yarn install - run
npx blitz prisma migrate devto create the database
This file contains hidden or 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
| // schema | |
| import { z } from 'zod' | |
| // structure for a blog post | |
| export const postCreateSchema = z.object({ | |
| title: z | |
| .string({ required_error: 'Title is required' }) | |
| .min(10, 'Title is too short'), | |
| body: z | |
| .string({ required_error: 'Body is required' }) |
This file contains hidden or 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
| import { faker } from '@faker-js/faker'; | |
| const MAX = 100 | |
| const users = [] | |
| const departaments = 'bridge engine'.split(' ') | |
| for (let i = 0; i < MAX; i++) { | |
| let firstName = faker.name.firstName(); | |
| let lastName = faker.name.lastName(); | |
| const user = { | |
| name: firstName + ' ' + lastName, |
This file contains hidden or 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
| let num = 0 //declare a variable whose initial value is zero | |
| //function declaration | |
| function increaseNum(){ | |
| num++ //increase the value of num by 1 using the increment operator | |
| //get the reference to the body element | |
| let bodyElement = document.getElementsByTagName('body')[0] | |
| //... and set its text value to the value of num |
This file contains hidden or 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
| //*** Object creation | |
| // 1) class syntax , usage: p = new Person('Rex') | |
| class Person { | |
| constructor(name) { | |
| this.name = name | |
| } | |
| sayHello() { |
This file contains hidden or 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
| let i = 1 //step | |
| //this implementation computes the sequence as an array | |
| function fib(n) { | |
| if (n === 1) { | |
| return [1, 1] | |
| } | |
| const prev = fib(n - 1) | |
| const rl = prev.length |
This file contains hidden or 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
| /* | |
| Write a recursive function that splits a string based on a separator (similar to String.prototype.split). | |
| Don't use JS array's split function to solve this problem. | |
| Input: 02/20/2020 | |
| Output: ["02", "20", "2020"] | |
| https://courses.thinkful.com/dsa-v1/checkpoint/2 |
This file contains hidden or 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
| try { | |
| // queries sequence | |
| const topicIDs = await knex('topics_users').select('topic_id').where('user_id', userID) | |
| const topics = await knex('topics').select('*').where('id', topicIDs) | |
| //single query | |
| const topicsInOneGo = await knex('topics').select('*') | |
| .innerJoin('topics_users', 'topics_users.id', 'topics.id') | |
| .where('topics_users.user_id', topicIDs) |
This file contains hidden or 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
| export default function Layout(props) { | |
| const classes = useStyles() | |
| const gc = useGlobalStyles() | |
| const { data: { user, loading } } = useContext(AppContext) | |
| console.log(`LOADING ${loading}`) | |
| const menuProps = { user } | |
| return ( |
This file contains hidden or 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
| // Toast/Snack | |
| import { NoSsr, Snackbar } from "@material-ui/core"; | |
| import { Alert } from "@material-ui/lab"; | |
| import React, { useEffect, useState } from "react"; | |
| export default function Snack(props) { | |
| const { message, severity = "success" } = props | |
| const [open, setOpen] = React.useState(null); | |
| useEffect(() => { |
NewerOlder