Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
.next/
.env
.env
/prisma/generated
32 changes: 12 additions & 20 deletions components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ const Header: React.FC = () => {

let left = (
<div className="left">
<Link href="/">
<a className="bold" data-active={isActive("/")}>
Feed
</a>
<Link href="/" className="bold" data-active={isActive("/")}>
Feed
</Link>
<style jsx>{`
.bold {
Expand Down Expand Up @@ -44,10 +42,8 @@ const Header: React.FC = () => {
if (status === 'loading') {
left = (
<div className="left">
<Link href="/">
<a className="bold" data-active={isActive("/")}>
Feed
</a>
<Link href="/" className="bold" data-active={isActive("/")}>
Feed
</Link>
<style jsx>{`
.bold {
Expand Down Expand Up @@ -85,8 +81,8 @@ const Header: React.FC = () => {
if (!session) {
right = (
<div className="right">
<Link href="/api/auth/signin">
<a data-active={isActive("/signup")}>Log in</a>
<Link href="/api/auth/signin" data-active={isActive("/signup")}>
Log in
</Link>
<style jsx>{`
a {
Expand Down Expand Up @@ -116,13 +112,11 @@ const Header: React.FC = () => {
if (session) {
left = (
<div className="left">
<Link href="/">
<a className="bold" data-active={isActive("/")}>
Feed
</a>
<Link href="/" className="bold" data-active={isActive("/")}>
Feed
</Link>
<Link href="/drafts">
<a data-active={isActive("/drafts")}>My drafts</a>
<Link href="/drafts" data-active={isActive("/drafts")}>
My drafts
</Link>
<style jsx>{`
.bold {
Expand Down Expand Up @@ -151,12 +145,10 @@ const Header: React.FC = () => {
{session.user.name} ({session.user.email})
</p>
<Link href="/create">
<button>
<a>New post</a>
</button>
<button>New post</button>
</Link>
<button onClick={() => signOut()}>
<a>Log out</a>
Log out
</button>
<style jsx>{`
a {
Expand Down
14 changes: 11 additions & 3 deletions lib/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PrismaClient } from "@prisma/client";
import { PrismaClient } from "../prisma/generated/client";
import { PrismaPg } from "@prisma/adapter-pg";

// PrismaClient is attached to the `global` object in development to prevent
// exhausting your database connection limit.
Expand All @@ -8,11 +9,18 @@ import { PrismaClient } from "@prisma/client";

let prisma: PrismaClient

const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL,
})
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient()
prisma = new PrismaClient({
adapter,
})
} else {
if (!global.prisma) {
global.prisma = new PrismaClient()
global.prisma = new PrismaClient({
adapter,
})
}
prisma = global.prisma
}
Expand Down
Loading