-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from seasonedcc/update-remix-to-rr
- Loading branch information
Showing
25 changed files
with
4,224 additions
and
8,052 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** @type {import('eslint').Linter.Config} */ | ||
module.exports = {} |
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,5 +1,6 @@ | ||
node_modules | ||
|
||
.react-router/ | ||
/.cache | ||
/build | ||
.env | ||
|
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
examples/remix/app/business/gpd.ts → examples/react-router/app/business/gpd.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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { Cookie } from 'react-router' | ||
import { data } from 'react-router' | ||
import type { Result } from 'composable-functions' | ||
import { catchFailure, serialize, fromSuccess } from 'composable-functions' | ||
|
||
/** | ||
* Given a Cookie and a Request it returns the stored cookie's value as an object, in case of failure it returns an empty object. | ||
*/ | ||
const safeReadCookie = catchFailure( | ||
async (request: Request, cookie: Cookie) => { | ||
const cookieHeader = request.headers.get('Cookie') | ||
const cookieObj = (await cookie.parse(cookieHeader)) as Record< | ||
string, | ||
unknown | ||
> | ||
if (!cookieObj) throw new Error('Cookie not found') | ||
|
||
return cookieObj | ||
}, | ||
() => ({}), | ||
) | ||
|
||
const ctxFromCookie = fromSuccess(safeReadCookie) | ||
|
||
const actionResponse = <X>(result: Result<X>, opts?: RequestInit): Result<X> => | ||
data(serialize(result), { | ||
status: result.success ? 200 : 422, | ||
...opts, | ||
}) as unknown as Result<X> | ||
|
||
export { ctxFromCookie, actionResponse } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { index, route, type RouteConfig } from '@react-router/dev/routes' | ||
|
||
export default [ | ||
index('./routes/home.tsx'), | ||
route('color/:id', './routes/color.tsx'), | ||
route('user/:id', './routes/user.tsx'), | ||
] satisfies RouteConfig |
21 changes: 12 additions & 9 deletions
21
examples/remix/app/routes/color.$id.tsx → examples/react-router/app/routes/color.tsx
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
15 changes: 7 additions & 8 deletions
15
examples/remix/app/routes/user.$id.tsx → examples/react-router/app/routes/user.tsx
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
File renamed without changes.
19 changes: 9 additions & 10 deletions
19
examples/remix/package.json → examples/react-router/package.json
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
Oops, something went wrong.