-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
23 changed files
with
376 additions
and
73 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Hono } from "hono"; | ||
import { rError, rOK } from "./helper"; | ||
import { unflatten } from "flat"; | ||
import { Entry, File, Form } from "@/db/schema"; | ||
import db from "@/lib/db"; | ||
import { eq } from "drizzle-orm"; | ||
import { validator } from "hono/validator"; | ||
import { ulid } from "ulid"; | ||
import query from "../lib/query"; | ||
import { getSession, getTeam } from "@/lib/auth"; | ||
import { handleFormUpload } from "@/components/model"; | ||
|
||
const form = new Hono() | ||
.get( | ||
"/get", | ||
async (c) => { | ||
const team = await getTeam(c.req.raw); | ||
if (!team) { | ||
return rError(c, "Unauthenticated"); | ||
} | ||
const r = await query.getViewComponentListByTeamId(team); | ||
return rOK(c, r); | ||
}, | ||
) | ||
.post( | ||
"/upload", | ||
validator("form", (v) => v), | ||
async (c) => { | ||
|
||
const team = await getTeam(c.req.raw); | ||
if (!team) { | ||
return rError(c, "Unauthenticated"); | ||
} | ||
const values = await handleFormUpload(c, null, team) as any; | ||
let id = values.file; | ||
if (typeof id !== 'string') { | ||
return rError(c, "Emm no shit"); | ||
} | ||
return rOK(c, id); | ||
}, | ||
) | ||
.post( | ||
"/delete/:id", | ||
async (c) => { | ||
let id = c.req.param("id"); | ||
let r = await db | ||
.delete(File) | ||
.where(eq(File.id, id)); | ||
if (r[0].affectedRows == 0) { | ||
return rError(c, "Emm no shit"); | ||
} | ||
return rOK(c); | ||
}, | ||
) | ||
|
||
export default form; |
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
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,13 @@ | ||
|
||
|
||
const fileSchema = { | ||
type: 'group', | ||
children: [{ | ||
label: 'File', | ||
id: 'file', | ||
type: 'file', | ||
required: true, | ||
},], | ||
} | ||
|
||
export default fileSchema; |
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
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
Oops, something went wrong.