diff --git a/.env b/.env
new file mode 100644
index 0000000..58b996f
--- /dev/null
+++ b/.env
@@ -0,0 +1,7 @@
+# Environment variables declared in this file are automatically made available to Prisma.
+# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
+
+# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
+# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
+
+DATABASE_URL="postgresql://postgres:hackme@localhost:5432/frasier-gifs?schema=public"
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..b58b603
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/frasier-gifs.iml b/.idea/frasier-gifs.iml
new file mode 100644
index 0000000..0c8867d
--- /dev/null
+++ b/.idea/frasier-gifs.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..03d9549
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..1a66899
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/models/Gif.ts b/models/Gif.ts
new file mode 100644
index 0000000..1d2acdf
--- /dev/null
+++ b/models/Gif.ts
@@ -0,0 +1,9 @@
+export interface Gif {
+ id: string;
+ title: string;
+ description: string;
+ fileName: string;
+ dateCreated: string;
+ upVotes: Number;
+ downVotes: Number;
+}
\ No newline at end of file
diff --git a/models/index.ts b/models/index.ts
new file mode 100644
index 0000000..9ae63cd
--- /dev/null
+++ b/models/index.ts
@@ -0,0 +1,3 @@
+import {Gif} from "./Gif";
+
+export type {Gif}
\ No newline at end of file
diff --git a/package.json b/package.json
index 6753812..5f1d7e0 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
+ "@prisma/client": "4.4.0",
"next": "12.3.1",
"react": "18.2.0",
"react-dom": "18.2.0"
@@ -21,6 +22,7 @@
"eslint": "8.24.0",
"eslint-config-next": "12.3.1",
"postcss": "^8.4.16",
+ "prisma": "^4.4.0",
"tailwindcss": "^3.1.8",
"typescript": "4.8.4"
}
diff --git a/pages/index.tsx b/pages/index.tsx
index 164249d..ff46457 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -1,10 +1,38 @@
-import type { NextPage } from "next";
-import Head from "next/head";
+import { PrismaClient } from "@prisma/client";
+import type { GetServerSideProps, NextPage } from "next";
+import { Gif } from "../models";
import Image from "next/image";
-import styles from "../styles/Home.module.css";
-const Home: NextPage = () => {
- return
Hello world!
;
+interface IHomeProps {
+ gifs: Gif[]
+}
+
+const Home: NextPage = ({ gifs }) => {
+ return (
+
+
+ Frasier Gifs
+
+
+ {gifs.map((gif: Gif) => {
+ return (
+
+
{gif.title}
+
+
+ )
+ })}
+
+
+ );
};
+export const getServerSideProps: GetServerSideProps = async ({ req }) => {
+ const prisma = new PrismaClient();
+ const gifs = await prisma.gif.findMany({
+ take: 12, orderBy: { title: 'asc' },
+ });
+
+ return { props: { gifs: JSON.parse(JSON.stringify(gifs)) } };
+};
export default Home;
diff --git a/prisma/migrations/20220928100354_initial/migration.sql b/prisma/migrations/20220928100354_initial/migration.sql
new file mode 100644
index 0000000..7a6ab5d
--- /dev/null
+++ b/prisma/migrations/20220928100354_initial/migration.sql
@@ -0,0 +1,12 @@
+-- CreateTable
+CREATE TABLE "Gif" (
+ "id" TEXT NOT NULL,
+ "title" VARCHAR(100) NOT NULL,
+ "description" VARCHAR(2000) NOT NULL,
+ "searchTerms" VARCHAR(2000) NOT NULL,
+ "upVotes" INTEGER NOT NULL DEFAULT 0,
+ "downVotes" INTEGER NOT NULL DEFAULT 0,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+
+ CONSTRAINT "Gif_pkey" PRIMARY KEY ("id")
+);
diff --git a/prisma/migrations/20220928101559_add_filename/migration.sql b/prisma/migrations/20220928101559_add_filename/migration.sql
new file mode 100644
index 0000000..ee90c79
--- /dev/null
+++ b/prisma/migrations/20220928101559_add_filename/migration.sql
@@ -0,0 +1,8 @@
+/*
+ Warnings:
+
+ - Added the required column `fileName` to the `Gif` table without a default value. This is not possible if the table is not empty.
+
+*/
+-- AlterTable
+ALTER TABLE "Gif" ADD COLUMN "fileName" VARCHAR(100) NOT NULL;
diff --git a/prisma/migrations/20220928102352_nullable_fields/migration.sql b/prisma/migrations/20220928102352_nullable_fields/migration.sql
new file mode 100644
index 0000000..e1e6b4f
--- /dev/null
+++ b/prisma/migrations/20220928102352_nullable_fields/migration.sql
@@ -0,0 +1,3 @@
+-- AlterTable
+ALTER TABLE "Gif" ALTER COLUMN "description" DROP NOT NULL,
+ALTER COLUMN "searchTerms" DROP NOT NULL;
diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml
new file mode 100644
index 0000000..fbffa92
--- /dev/null
+++ b/prisma/migrations/migration_lock.toml
@@ -0,0 +1,3 @@
+# Please do not edit this file manually
+# It should be added in your version-control system (i.e. Git)
+provider = "postgresql"
\ No newline at end of file
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
new file mode 100644
index 0000000..adee240
--- /dev/null
+++ b/prisma/schema.prisma
@@ -0,0 +1,25 @@
+// This is your Prisma schema file,
+// learn more about it in the docs: https://pris.ly/d/prisma-schema
+
+generator client {
+ provider = "prisma-client-js"
+}
+
+datasource db {
+ provider = "postgresql"
+ url = env("DATABASE_URL")
+}
+
+model Gif {
+ id String @id @default(uuid())
+
+ title String @db.VarChar(100)
+ description String? @db.VarChar(2000)
+ searchTerms String? @db.VarChar(2000)
+ //this is temporary, filenames should always match the GUID above
+ fileName String @db.VarChar(100)
+ upVotes Int @default(0)
+ downVotes Int @default(0)
+
+ createdAt DateTime @default(now())
+}
diff --git a/public/samples/sample-1.gif b/public/samples/sample-1.gif
new file mode 100644
index 0000000..9604fd8
Binary files /dev/null and b/public/samples/sample-1.gif differ
diff --git a/public/samples/sample-10.gif b/public/samples/sample-10.gif
new file mode 100644
index 0000000..00f3cca
Binary files /dev/null and b/public/samples/sample-10.gif differ
diff --git a/public/samples/sample-11.gif b/public/samples/sample-11.gif
new file mode 100644
index 0000000..2e5459e
Binary files /dev/null and b/public/samples/sample-11.gif differ
diff --git a/public/samples/sample-12.gif b/public/samples/sample-12.gif
new file mode 100644
index 0000000..7cd9184
Binary files /dev/null and b/public/samples/sample-12.gif differ
diff --git a/public/samples/sample-2.gif b/public/samples/sample-2.gif
new file mode 100644
index 0000000..8921845
Binary files /dev/null and b/public/samples/sample-2.gif differ
diff --git a/public/samples/sample-3.gif b/public/samples/sample-3.gif
new file mode 100644
index 0000000..06f87ca
Binary files /dev/null and b/public/samples/sample-3.gif differ
diff --git a/public/samples/sample-4.gif b/public/samples/sample-4.gif
new file mode 100644
index 0000000..e344d09
Binary files /dev/null and b/public/samples/sample-4.gif differ
diff --git a/public/samples/sample-5.gif b/public/samples/sample-5.gif
new file mode 100644
index 0000000..23418ad
Binary files /dev/null and b/public/samples/sample-5.gif differ
diff --git a/public/samples/sample-6.gif b/public/samples/sample-6.gif
new file mode 100644
index 0000000..b9215a2
Binary files /dev/null and b/public/samples/sample-6.gif differ
diff --git a/public/samples/sample-7.gif b/public/samples/sample-7.gif
new file mode 100644
index 0000000..2434c94
Binary files /dev/null and b/public/samples/sample-7.gif differ
diff --git a/public/samples/sample-8.gif b/public/samples/sample-8.gif
new file mode 100644
index 0000000..2f338c3
Binary files /dev/null and b/public/samples/sample-8.gif differ
diff --git a/public/samples/sample-9.gif b/public/samples/sample-9.gif
new file mode 100644
index 0000000..7f89b5b
Binary files /dev/null and b/public/samples/sample-9.gif differ
diff --git a/yarn.lock b/yarn.lock
index 904edcc..319e961 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -154,6 +154,23 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"
+"@prisma/client@4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@prisma/client/-/client-4.4.0.tgz#45f59c172dd3621ecc92d7cf9bc765d85e6c7d56"
+ integrity sha512-ciKOP246x1xwr04G9ajHlJ4pkmtu9Q6esVyqVBO0QJihaKQIUvbPjClp17IsRJyxqNpFm4ScbOc/s9DUzKHINQ==
+ dependencies:
+ "@prisma/engines-version" "4.4.0-66.f352a33b70356f46311da8b00d83386dd9f145d6"
+
+"@prisma/engines-version@4.4.0-66.f352a33b70356f46311da8b00d83386dd9f145d6":
+ version "4.4.0-66.f352a33b70356f46311da8b00d83386dd9f145d6"
+ resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-4.4.0-66.f352a33b70356f46311da8b00d83386dd9f145d6.tgz#00875863bb30b670a586a5b5794a000f7f3ad976"
+ integrity sha512-P5v/PuEIJLYXZUZBvOLPqoyCW+m6StNqHdiR6te++gYVODpPdLakks5HVx3JaZIY+LwR02juJWFlwpc9Eog/ug==
+
+"@prisma/engines@4.4.0":
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-4.4.0.tgz#6ca7d3ce8eee08dcfa82311b0a02f5ccaac7dc0c"
+ integrity sha512-Fpykccxlt9MHrAs/QpPGpI2nOiRxuLA+LiApgA59ibbf24YICZIMWd3SI2YD+q0IAIso0jCGiHhirAIbxK3RyQ==
+
"@rushstack/eslint-patch@^1.1.3":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz#8be36a1f66f3265389e90b5f9c9962146758f728"
@@ -1630,6 +1647,13 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
+prisma@^4.4.0:
+ version "4.4.0"
+ resolved "https://registry.yarnpkg.com/prisma/-/prisma-4.4.0.tgz#0c53324bf6a29474636b3e1964e0d72e0277bf8f"
+ integrity sha512-l/QKLmLcKJQFuc+X02LyICo0NWTUVaNNZ00jKJBqwDyhwMAhboD1FWwYV50rkH4Wls0RviAJSFzkC2ZrfawpfA==
+ dependencies:
+ "@prisma/engines" "4.4.0"
+
prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"