-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
72 changed files
with
230 additions
and
370 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
8 changes: 4 additions & 4 deletions
8
apps/showcase-forest-real-world-breaking-bad/src/features/quote/contract.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { Record, String } from 'runtypes'; | ||
import { obj, str } from '@withease/contracts'; | ||
|
||
export const Quote = Record({ | ||
author: String, | ||
quote: String, | ||
export const Quote = obj({ | ||
author: str, | ||
quote: str, | ||
}); |
This file contains 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
This file contains 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
This file contains 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
16 changes: 6 additions & 10 deletions
16
apps/showcase-react-real-world-pokemons/src/entities/pokemon/api.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
import { TId } from '../../shared/id'; | ||
export function pokemonUrl(): string; | ||
export function pokemonUrl({ id }: { id: number }): string; | ||
|
||
function pokemonUrl(): string; | ||
function pokemonUrl({ id }: { id: TId }): string; | ||
|
||
function pokemonUrl(params?: { id: TId }) { | ||
export function pokemonUrl(params?: { id: number }) { | ||
if (params?.id) { | ||
return `https://pokeapi.co/api/v2/pokemon/${params.id}`; | ||
} | ||
|
||
return 'https://pokeapi.co/api/v2/pokemon'; | ||
} | ||
|
||
function speciesUrl(): string; | ||
function speciesUrl({ id }: { id: TId }): string; | ||
export function speciesUrl(): string; | ||
export function speciesUrl({ id }: { id: number }): string; | ||
|
||
function speciesUrl(params?: { id: TId }) { | ||
export function speciesUrl(params?: { id: number }) { | ||
if (params?.id) { | ||
return `https://pokeapi.co/api/v2/pokemon-species/${params.id}`; | ||
} | ||
|
||
return 'https://pokeapi.co/api/v2/pokemon-species'; | ||
} | ||
|
||
export { pokemonUrl, speciesUrl }; |
22 changes: 10 additions & 12 deletions
22
apps/showcase-react-real-world-pokemons/src/entities/pokemon/contract.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
import { Number, Record, String } from 'runtypes'; | ||
import { obj, num, str } from '@withease/contracts'; | ||
|
||
import { EntityLink } from '../../shared/entity_link'; | ||
import { Id } from '../../shared/id'; | ||
import { Url } from '../../shared/url'; | ||
|
||
export const Pokemon = Record({ | ||
id: Id, | ||
name: String, | ||
height: Number, | ||
weight: Number, | ||
sprites: Record({ front_default: Url }), | ||
export const Pokemon = obj({ | ||
id: num, | ||
name: str, | ||
height: num, | ||
weight: num, | ||
sprites: obj({ front_default: str }), | ||
species: EntityLink, | ||
}); | ||
|
||
export const Species = Record({ | ||
id: Id, | ||
name: String, | ||
export const Species = obj({ | ||
id: num, | ||
name: str, | ||
color: EntityLink, | ||
generation: EntityLink, | ||
}); |
This file contains 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
This file contains 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
10 changes: 4 additions & 6 deletions
10
apps/showcase-react-real-world-pokemons/src/shared/entity_link.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import { Record, String } from 'runtypes'; | ||
import { obj, str } from '@withease/contracts'; | ||
|
||
import { Url } from './url'; | ||
|
||
export const EntityLink = Record({ | ||
name: String, | ||
url: Url, | ||
export const EntityLink = obj({ | ||
name: str, | ||
url: str, | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
import { Number, Static } from 'runtypes'; | ||
|
||
import { TUrl } from './url'; | ||
|
||
const Id = Number.withBrand('Id'); | ||
|
||
type TId = Static<typeof Id>; | ||
|
||
function urlToId(url: TUrl): TId { | ||
export function urlToId(url: string): string { | ||
return parseInt(url.split('/').filter(Boolean).at(-1) ?? '', 10) as TId; | ||
} | ||
export { urlToId, Id, type TId }; |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
35 changes: 15 additions & 20 deletions
35
apps/showcase-solid-real-world-rick-morty/src/entities/character/contract.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
import { Array, Literal, Record, String, Union } from 'runtypes'; | ||
import { arr, val, obj, str, or, num } from '@withease/contracts'; | ||
|
||
import { Id } from '../../shared/id'; | ||
import { Url } from '../../shared/url'; | ||
const UnknownLiteral = val('unknown'); | ||
|
||
const UnknownLiteral = Literal('unknown'); | ||
const Status = or(val('Alive'), val('Dead'), UnknownLiteral); | ||
|
||
const Status = Union(Literal('Alive'), Literal('Dead'), UnknownLiteral); | ||
|
||
const Gender = Union( | ||
Literal('Female'), | ||
Literal('Male'), | ||
Literal('Genderless'), | ||
const Gender = or( | ||
val('Female'), | ||
val('Male'), | ||
val('Genderless'), | ||
UnknownLiteral | ||
); | ||
|
||
const LocationLink = Record({ name: String, url: Url }); | ||
const LocationLink = obj({ name: str, url: str }); | ||
|
||
const Character = Record({ | ||
id: Id, | ||
name: String, | ||
export const Character = obj({ | ||
id: num, | ||
name: str, | ||
status: Status, | ||
species: String, | ||
type: String, | ||
species: str, | ||
type: str, | ||
gender: Gender, | ||
origin: LocationLink, | ||
location: LocationLink, | ||
image: Url, | ||
episode: Array(Url), | ||
episode: arr(str), | ||
image: str, | ||
}); | ||
|
||
export { Character }; |
8 changes: 2 additions & 6 deletions
8
apps/showcase-solid-real-world-rick-morty/src/entities/character/model.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
import { createRoute } from 'atomic-router'; | ||
|
||
import { TId } from '../../shared/id'; | ||
|
||
const characterRoute = createRoute<{ characterId: TId }>(); | ||
const characterListRoute = createRoute<{ page?: number }>(); | ||
|
||
export { characterRoute, characterListRoute }; | ||
export const characterRoute = createRoute<{ characterId: number }>(); | ||
export const characterListRoute = createRoute<{ page?: number }>(); |
Oops, something went wrong.