diff --git a/README.md b/README.md index e215bc4..4270b55 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,7 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. + + +# Structure +Store on local machine and use a middleware to process (compress) the file and facilitate storage. \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 1b48155..fababeb 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 258fc9b..3b19ef7 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,10 @@ "lint": "next lint" }, "dependencies": { + "bun-types": "^1.2.9", + "next": "15.3.0", "react": "^19.0.0", - "react-dom": "^19.0.0", - "next": "15.3.0" + "react-dom": "^19.0.0" }, "devDependencies": { "typescript": "^5", diff --git a/services/docker-compose.yml b/services/docker-compose.yml new file mode 100644 index 0000000..c78fffd --- /dev/null +++ b/services/docker-compose.yml @@ -0,0 +1,15 @@ +services: + postgres: + image: postgres:17.4-alpine3.21 + restart: always + shm_size: 128mb + environment: + - POSTGRES_PASSWORD=test + - POSTGRES_USER=test + ports: + - 5432:5432 + adminer: + image: adminer + restart: always + ports: + - 8080:8080 \ No newline at end of file diff --git a/src/app/page.tsx b/src/app/page.tsx index e68abe6..25af71e 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,103 +1,15 @@ -import Image from "next/image"; +import { retrieve_post } from "@/db"; export default function Home() { - return ( -
-
- Next.js logo -
    -
  1. - Get started by editing{" "} - - src/app/page.tsx - - . -
  2. -
  3. - Save and see your changes instantly. -
  4. -
-
- - Vercel logomark - Deploy now - - - Read our docs - -
-
- + return ( +
+
+

匿名中工

+
+
+ +
); } diff --git a/src/app/post.tsx b/src/app/post.tsx new file mode 100644 index 0000000..4f0ea0f --- /dev/null +++ b/src/app/post.tsx @@ -0,0 +1,35 @@ + +import { Suspense } from "react"; +import Image from "next/image"; +import { Attachment } from "@/db"; + +export default function Post(post_content: string, attachments: Attachment[]) { + let images = []; + let videos = []; + attachments.forEach(attachment => { + if (attachment.type.type == "video") { + attachment.urls.forEach(url => { + videos.push( + 加載中

}> + +
+ ) + }) + }else if (attachment.type.type="image"){ + attachment.urls.forEach(url => { + images.push(Uploaded) + }) + } + }) + return (
+
+ {post_content} +
+
+
+
+
) +} \ No newline at end of file diff --git a/src/db.ts b/src/db.ts new file mode 100644 index 0000000..a31fb47 --- /dev/null +++ b/src/db.ts @@ -0,0 +1,57 @@ +import { main } from "bun"; +import { sql } from "bun"; +import { MIMEType } from "util" + +export interface Attachment { + type: MIMEType; + urls: string[]; +} +export interface Post { + content: string, + hash: string, +} + +export async function setup_func() { + const rows = await sql` + CREATE OR REPLACE FUNCTION fetch_post( + OUT p_text VARCHAR(1000), + OUT p_hash CHAR(32), + OUT p_date TIMESTAMP, + OUT p_pics INT[] + ) + RETURNS SETOF RECORD AS + $$ + DECLARE + post_cursor CURSOR FOR + SELECT content, hash, date + FROM posts; + post_record RECORD; + BEGIN + -- Open cursor + OPEN post_cursor; + + -- Fetch rows and return + LOOP + FETCH NEXT FROM post_cursor INTO post_record; + EXIT WHEN NOT FOUND; + + p_text = post_record.content; + p_date = post_record.date; + p_hash = post_record.hash; + RETURN NEXT; + END LOOP; + + -- Close cursor + CLOSE post_cursor; + END; + $$ + LANGUAGE PLPGSQL;`; +} + +/* retrieve the latest post with posts table */ +export async function retrieve_post(offset: Number) { + const res = await sql`SELECT * FROM fetch_post();` + console.log(res) +} +setup_func() +retrieve_post(0) \ No newline at end of file