diff --git a/app/entry.server.tsx b/app/entry.server.tsx
index 09a11e4..aa0aa09 100644
--- a/app/entry.server.tsx
+++ b/app/entry.server.tsx
@@ -1,4 +1,3 @@
-import 'dotenv/config'
import type { EntryContext } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import { renderToString } from "react-dom/server";
diff --git a/app/routes/index.tsx b/app/routes/index.tsx
index 84df05f..a893ee1 100644
--- a/app/routes/index.tsx
+++ b/app/routes/index.tsx
@@ -19,9 +19,10 @@ export default function Index() {
return (
Welcome to Remix Heroku
+
Add a new note
Notes:
- {data.notes.map(({ id, name }) => ( - id: {id} name: {name}
))}
+ {data.notes.map(({ id, name, content }) => ( - id: {id} name: {name} content: {content}
))}
diff --git a/app/routes/new.tsx b/app/routes/new.tsx
new file mode 100644
index 0000000..1b3990c
--- /dev/null
+++ b/app/routes/new.tsx
@@ -0,0 +1,50 @@
+import type { ActionFunction } from "@remix-run/node";
+import { redirect } from "@remix-run/node";
+
+import { db } from "~/utils/db.server";
+
+export const action: ActionFunction = async ({
+ request,
+}) => {
+ const form = await request.formData();
+ const name = form.get("name");
+ const content = form.get("content");
+ // we do this type check to be extra sure and to make TypeScript happy
+ if (
+ typeof name !== "string" ||
+ typeof content !== "string"
+ ) {
+ throw new Error(`Form not submitted correctly.`);
+ }
+
+ const fields = { name, content };
+
+ await db.note.create({ data: fields });
+ return redirect(`/`);
+};
+
+
+export default function NewNote() {
+ return (
+
+ );
+ }
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index c114d98..eaa2693 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,7 +10,6 @@
"@remix-run/node": "^1.3.4",
"@remix-run/react": "^1.3.4",
"@remix-run/serve": "^1.3.4",
- "dotenv": "^16.0.0",
"prisma": "^3.12.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
@@ -3116,6 +3115,7 @@
"version": "16.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz",
"integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==",
+ "dev": true,
"engines": {
"node": ">=12"
}
@@ -12104,7 +12104,8 @@
"dotenv": {
"version": "16.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz",
- "integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q=="
+ "integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==",
+ "dev": true
},
"duplexify": {
"version": "3.7.1",
diff --git a/package.json b/package.json
index 24c9cbc..bca646b 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,6 @@
"@remix-run/node": "^1.3.4",
"@remix-run/react": "^1.3.4",
"@remix-run/serve": "^1.3.4",
- "dotenv": "^16.0.0",
"prisma": "^3.12.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
diff --git a/prisma/migrations/20220407132919_init/migration.sql b/prisma/migrations/20220407141313_init/migration.sql
similarity index 80%
rename from prisma/migrations/20220407132919_init/migration.sql
rename to prisma/migrations/20220407141313_init/migration.sql
index 0adc278..3fbc1a7 100644
--- a/prisma/migrations/20220407132919_init/migration.sql
+++ b/prisma/migrations/20220407141313_init/migration.sql
@@ -2,6 +2,7 @@
CREATE TABLE "Note" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
+ "content" TEXT NOT NULL,
CONSTRAINT "Note_pkey" PRIMARY KEY ("id")
-);
\ No newline at end of file
+);
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 16d5887..8e11d37 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -14,4 +14,5 @@ datasource db {
model Note {
id Int @id @default(autoincrement())
name String
+ content String
}
\ No newline at end of file
diff --git a/prisma/seed.ts b/prisma/seed.ts
index 1ab7d43..0d57ca7 100644
--- a/prisma/seed.ts
+++ b/prisma/seed.ts
@@ -2,7 +2,7 @@ import { PrismaClient } from "@prisma/client";
const db = new PrismaClient();
async function seed() {
- return db.note.create({ data: { name: "Note from the databae" }});
+ return db.note.create({ data: { name: "Note from the databae", content: " I am a new note :) " }});
}
seed();