-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
9 changed files
with
72 additions
and
210 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { react } from "./react"; | ||
export { next } from "./next"; | ||
export { root } from "./root"; |
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,18 @@ | ||
import { getHooks } from "../services/hooks.service"; | ||
import { Elysia, t } from "elysia"; | ||
|
||
export const next = new Elysia() | ||
.get( | ||
"/next", | ||
({ query }) => | ||
getHooks({ search: query.search, limit: query.limit, type: "next" }), | ||
{ | ||
query: t.Object({ | ||
search: t.Optional(t.String()), | ||
limit: t.Optional(t.Integer()), | ||
}), | ||
}, | ||
) | ||
.get("/next/:title", ({ params }) => | ||
getHooks({ search: params.title, type: "next" }), | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
export type Hook = Readonly<{ | ||
export type React = Readonly<{ | ||
id: number; | ||
title: string; | ||
description: string; | ||
content: string; | ||
}>; | ||
|
||
export type Next = Readonly<{ | ||
id: number; | ||
title: string; | ||
description: string; | ||
content: Opts; | ||
}>; | ||
|
||
type Opts = { | ||
server: string; | ||
client: string; | ||
}; | ||
|
||
export type CondHooks = Next | React; |
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,16 +1,17 @@ | ||
import type { Hook } from "~/types/hook"; | ||
import type { CondHooks } from "~/types/hook"; | ||
|
||
const createFilter = | ||
<T extends keyof Hook>(key: T) => | ||
<T extends keyof CondHooks>(key: T) => | ||
(search: string) => | ||
(hook: Hook) => { | ||
(hook: CondHooks) => { | ||
const value = hook[key]; | ||
if (typeof value === "string") { | ||
return value.toLowerCase().includes(search.toLowerCase()); | ||
} | ||
return false; | ||
}; | ||
|
||
const createLimit = (limit: number) => (hooks: Hook[]) => hooks.slice(0, limit); | ||
const createLimit = (limit: number) => (hooks: CondHooks[]) => | ||
hooks.slice(0, limit); | ||
|
||
export { createFilter, createLimit }; |