Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export @fartlabs/jsonx/jsx-runtime #6

Merged
merged 2 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ Let's learn how to get started with rtx by creating a simple router in Deno.
deno init
```

3\. Add `@fartlabs/jsonx` and `@fartlabs/rtx` as project dependencies.
3\. Add `@fartlabs/rtx` as a project dependency.

```sh
deno add @fartlabs/jsonx @fartlabs/rtx
deno add @fartlabs/rtx
```

4\. Add the following values to your `deno.json(c)` file.
Expand All @@ -36,7 +36,7 @@ deno add @fartlabs/jsonx @fartlabs/rtx
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@fartlabs/jsonx"
"jsxImportSource": "@fartlabs/rtx"
}
}
```
Expand Down
5 changes: 4 additions & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"lock": false,
"name": "@fartlabs/rtx",
"version": "0.0.4",
"exports": "./mod.ts",
"exports": {
"./": "./mod.ts",
"./jsx-runtime": "./jsx-runtime.ts"
},
"imports": {
"@fartlabs/jsonx": "jsr:@fartlabs/jsonx@^0.0.10",
"@fartlabs/rt": "jsr:@fartlabs/rt@^0.0.3"
Expand Down
1 change: 1 addition & 0 deletions jsx-runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "@fartlabs/jsonx/jsx-runtime";
26 changes: 13 additions & 13 deletions rtx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createRouter, Router as CRouter } from "@fartlabs/rt";
*/
export type ComponentsInterface = Record<
Capitalize<Lowercase<IMethod>>,
(props: RouteProps) => CRouter
(props: RouteProps) => CRouter<unknown>
>;

/**
Expand All @@ -34,9 +34,9 @@ export interface RouterProps {
/**
* Router is the router component.
*/
export function Router(props: RouterProps): CRouter {
export function Router(props: RouterProps): CRouter<unknown> {
const router = createRouter();
((props.children) as CRouter[])
((props.children) as CRouter<unknown>[])
?.forEach((child) => {
if (child instanceof CRouter) {
router.use(child);
Expand All @@ -60,69 +60,69 @@ export function Router(props: RouterProps): CRouter {
/**
* Route is the route component.
*/
export function Route(props: IRoute): CRouter {
export function Route(props: IRoute): CRouter<unknown> {
return createRouter().with(props);
}

/**
* Connect is the route component for a CONNECT route.
*/
export function Connect(props: RouteProps): CRouter {
export function Connect(props: RouteProps): CRouter<unknown> {
return createRouter().connect(props.pattern, props.handle);
}

/**
* Delete is the route component for a DELETE route.
*/
export function Delete(props: RouteProps): CRouter {
export function Delete(props: RouteProps): CRouter<unknown> {
return createRouter().delete(props.pattern, props.handle);
}

/**
* Get is the route component for a GET route.
*/
export function Get(props: RouteProps): CRouter {
export function Get(props: RouteProps): CRouter<unknown> {
return createRouter().get(props.pattern, props.handle);
}

/**
* Head is the route component for a HEAD route.
*/
export function Head(props: RouteProps): CRouter {
export function Head(props: RouteProps): CRouter<unknown> {
return createRouter().head(props.pattern, props.handle);
}

/**
* Options is the route component for a OPTIONS route.
*/
export function Options(props: RouteProps): CRouter {
export function Options(props: RouteProps): CRouter<unknown> {
return createRouter().options(props.pattern, props.handle);
}

/**
* Patch is the route component for a PATCH route.
*/
export function Patch(props: RouteProps): CRouter {
export function Patch(props: RouteProps): CRouter<unknown> {
return createRouter().patch(props.pattern, props.handle);
}

/**
* Post is the route component for a POST route.
*/
export function Post(props: RouteProps): CRouter {
export function Post(props: RouteProps): CRouter<unknown> {
return createRouter().post(props.pattern, props.handle);
}

/**
* Put is the route component for a PUT route.
*/
export function Put(props: RouteProps): CRouter {
export function Put(props: RouteProps): CRouter<unknown> {
return createRouter().put(props.pattern, props.handle);
}

/**
* Trace is the route component for a TRACE route.
*/
export function Trace(props: RouteProps): CRouter {
export function Trace(props: RouteProps): CRouter<unknown> {
return createRouter().trace(props.pattern, props.handle);
}