Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Mar 25, 2024
1 parent 448f5ee commit f021341
Show file tree
Hide file tree
Showing 110 changed files with 4,875 additions and 78 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
Here are some resources you can read before taking the workshop to get you up to
speed on some of the tools and concepts we'll be covering:

- TODO: add resources
- ["React from Another Dimension" by Dan Abramov at Remix Conf 2023](https://www.youtube.com/watch?v=zMf_xeGPn6s)

## System Requirements

Expand Down
1 change: 1 addition & 0 deletions exercises/01.start/01.problem.start/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 3 additions & 0 deletions exercises/01.start/01.problem.start/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
package-lock.json
built_node_modules
28 changes: 28 additions & 0 deletions exercises/01.start/01.problem.start/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"arrowParens": "avoid",
"bracketSameLine": false,
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "always",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": false,
"singleAttributePerLine": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": true,
"overrides": [
{
"files": ["**/*.json"],
"options": {
"useTabs": false
}
}
]
}
3 changes: 3 additions & 0 deletions exercises/01.start/01.problem.start/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Beginning

This is the beginning form probably.
47 changes: 47 additions & 0 deletions exercises/01.start/01.problem.start/db/ship-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import fs from 'node:fs/promises'

const shipData = JSON.parse(
String(await fs.readFile(new URL('./ships.json', import.meta.url))),
)

export async function searchShips({
search,
delay = Math.random() * 200 + 300,
}) {
const endTime = Date.now() + delay
const ships = shipData
.filter(ship => ship.name.toLowerCase().includes(search.toLowerCase()))
.slice(0, 13)
await new Promise(resolve => setTimeout(resolve, endTime - Date.now()))
return {
ships: ships.map(ship => ({ name: ship.name, id: ship.id })),
}
}

export async function getShip({ shipId, delay = Math.random() * 200 + 300 }) {
const endTime = Date.now() + delay
if (!shipId) {
throw new Error('No shipId provided')
}
const ship = shipData.find(ship => ship.id === shipId)
await new Promise(resolve => setTimeout(resolve, endTime - Date.now()))
if (!ship) {
throw new Error(`No ship with the id "${shipId}"`)
}
return ship
}

export async function updateShipName({
shipId,
shipName,
delay = Math.random() * 200 + 300,
}) {
const endTime = Date.now() + delay
const ship = shipData.find(ship => ship.id === shipId)
await new Promise(resolve => setTimeout(resolve, endTime - Date.now()))
if (!ship) {
throw new Error(`No ship with the id "${shipId}"`)
}
ship.name = shipName
return ship
}
Loading

0 comments on commit f021341

Please sign in to comment.