-
Notifications
You must be signed in to change notification settings - Fork 3
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
6 changed files
with
103 additions
and
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function isConstructor(value: any) { | ||
return typeof value === "function" && value.prototype !== undefined; | ||
return typeof value === "function" && typeof value.constructor === "function"; | ||
} |
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,65 +1,21 @@ | ||
import { prisma } from "@/app/database/prisma"; | ||
import { ApiRouter, HttpRequest, ResourceController } from "gemi/http"; | ||
import { | ||
ApiRouter, | ||
HttpRequest, | ||
ResourceController, | ||
type CreateRPC, | ||
} from "gemi/http"; | ||
import { Auth, Broadcast, FileStorage } from "gemi/facades"; | ||
import { WelcomeEmail } from "@/app/email/WelcomeEmail"; | ||
import { FooController } from "../controllers/FooController"; | ||
|
||
export default class extends ApiRouter { | ||
class A extends ApiRouter { | ||
routes = { | ||
"/users": this.get(async () => { | ||
return await prisma.user.findFirst(); | ||
}), | ||
"/home": this.get(async (req: HttpRequest<{ color: string }>) => { | ||
const input = req.search; | ||
const items = [ | ||
{ id: 1, name: "Red", hex: "#FF0000", color: "red" }, | ||
{ id: 2, name: "Green", hex: "#00FF00", color: "green" }, | ||
{ id: 3, name: "Blue", hex: "#0000FF", color: "blue" }, | ||
{ id: 4, name: "Yellow", hex: "#FFFF00", color: "yellow" }, | ||
{ id: 5, name: "Purple", hex: "#800080", color: "purple" }, | ||
]; | ||
const filteredItems = items.filter((item) => | ||
input.get("color") | ||
? input.get("color").split(".").includes(item.color) | ||
: true, | ||
); | ||
|
||
return filteredItems; | ||
}), | ||
|
||
"/test/:testId": this.get((req: HttpRequest) => { | ||
return `${req.params.testId}`; | ||
}), | ||
|
||
"/email": this.get(async () => { | ||
const result = await WelcomeEmail.send({ data: { name: "Enes" } }); | ||
return { success: result }; | ||
}), | ||
|
||
"/upload": this.post(async (req: HttpRequest<{ images: Blob[] }>) => { | ||
const input = await req.input(); | ||
console.log(input.get("images")); | ||
return {}; | ||
}), | ||
"/foo": this.resource(FooController, "fooId"), | ||
"/file/:path*": this.get(async (req: HttpRequest<{ path: string }>) => { | ||
return await FileStorage.fetch(req.params.path); | ||
}), | ||
"/invite": this.get(async () => { | ||
return await prisma.organizationInvitation.create({ | ||
data: { | ||
email: "enesxtufekci+2@gmail.com", | ||
organizationId: 1, | ||
role: 0, | ||
}, | ||
}); | ||
}), | ||
"/organization": this.get(async () => { | ||
return await prisma.organization.create({ | ||
data: { | ||
name: "Enes org", | ||
}, | ||
}); | ||
}), | ||
"/test": this.post(FooController, "index"), | ||
"/foo": this.resource(FooController), | ||
}; | ||
} | ||
|
||
type X = CreateRPC<A>; | ||
|
||
export default A; |
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