From 60e76089f3c7bb8cdb4a4497e9e439b7656f64af Mon Sep 17 00:00:00 2001 From: Aaron William Po Date: Sun, 14 May 2023 14:57:19 -0400 Subject: [PATCH] Update README and env to mention Neon PG --- README.md | 27 +++++++------ src/config/env/index.ts | 67 ++++---------------------------- src/hooks/utilities/useNavbar.ts | 2 +- 3 files changed, 21 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 981de35..4255c2f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ The Biergarten App is a web application designed for beer lovers to share their favorite brews and breweries with like-minded people online. -This application's stack consists of Next.js, Prisma and Vercel Postgres. I'm motivated to +This application's stack consists of Next.js, Prisma and Neon Postgres. I'm motivated to learn more about these technologies while exploring my passion for beer. I've also incorporated different APIs into the application, such as the Cloudinary API for @@ -66,8 +66,8 @@ beer known as iso-alpha acids. - [Prisma](https://www.prisma.io/) - An open-source ORM for Node.js and TypeScript applications. -- [Vercel Postgres](https://vercel.com/dashboard/stores) - - A managed PostgreSQL database service provided by Vercel. +- [Neon Postgres](https://neon.tech/) + - A managed PostgreSQL database service powered by Neon. - [Cloudinary](https://cloudinary.com/) - A cloud-based image and video management service that provides developers with an easy way to upload, store, and manipulate media assets. @@ -94,7 +94,7 @@ You will also need to create a free account with the following services: - [Cloudinary](https://cloudinary.com/users/register/free) - [SparkPost](https://www.sparkpost.com/) -- [Vercel Postgres](https://vercel.com/dashboard/stores) +- [Neon Postgres](https://neon.tech/) - [Mapbox](https://account.mapbox.com/auth/signup/) ### Setup @@ -126,13 +126,11 @@ SESSION_SECRET= SESSION_TOKEN_NAME= SESSION_MAX_AGE= NODE_ENV= -POSTGRES_URL= + POSTGRES_PRISMA_URL= POSTGRES_URL_NON_POOLING= -POSTGRES_USER= -POSTGRES_HOST= -POSTGRES_PASSWORD= -POSTGRES_DATABASE= +SHADOW_DATABASE_URL= + MAPBOX_ACCESS_TOKEN= NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN= SPARKPOST_API_KEY= @@ -156,10 +154,11 @@ SPARKPOST_SENDER_ADDRESS=" > .env - You can set this to `biergarten`. - `SESSION_MAX_AGE` is the maximum age of the session cookie in milliseconds. - You can set this to `604800000` (1 week). -- `POSTGRES_URL`, `POSTGRES_PRISMA_URL`, `POSTGRES_URL_NON_POOLING`, `POSTGRES_USER`, - `POSTGRES_HOST`, `POSTGRES_PASSWORD`, and `POSTGRES_DATABASE` are the credentials for - your Vercel Postgres database. - - You can create a free account [here](https://vercel.com/dashboard/stores). +- `POSTGRES_PRISMA_URL`is a pooled connection string for your Neon Postgres database. +- `POSTGRES_URL_NON_POOLING` is a non-pooled connection string for your Neon Postgres database used for migrations. +- `SHADOW_DATABASE_URL` is a connection string for a secondary database used for migrations to detect schema drift. + - You can create a free account [here](https://neon.tech) + - Consult the [docs](https://neon.tech/docs/guides/prisma) for more information. - `MAPBOX_ACCESS_TOKEN` and `NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN` are the access tokens for your Mapbox account. - You can create a free account [here](https://account.mapbox.com/auth/signup/). @@ -171,7 +170,7 @@ SPARKPOST_SENDER_ADDRESS=" > .env - You can create a free account [here](https://www.sparkpost.com/). - `SPARKPOST_SENDER_ADDRESS` is the email address that will be used to send emails. -4. Initialize the database and run the migrations. +1. Initialize the database and run the migrations. ```bash npx prisma generate diff --git a/src/config/env/index.ts b/src/config/env/index.ts index 0b4fc36..9567c3f 100644 --- a/src/config/env/index.ts +++ b/src/config/env/index.ts @@ -19,13 +19,8 @@ const envSchema = z.object({ SESSION_TOKEN_NAME: z.string(), SESSION_MAX_AGE: z.coerce.number().positive(), - POSTGRES_URL: z.string().url(), POSTGRES_PRISMA_URL: z.string().url(), POSTGRES_URL_NON_POOLING: z.string().url(), - POSTGRES_USER: z.string(), - POSTGRES_PASSWORD: z.string(), - POSTGRES_DATABASE: z.string(), - POSTGRES_HOST: z.string(), SHADOW_DATABASE_URL: z.string().url(), NODE_ENV: z.enum(['development', 'production', 'test']), @@ -119,80 +114,32 @@ export const SESSION_TOKEN_NAME = parsed.data.SESSION_TOKEN_NAME; export const SESSION_MAX_AGE = parsed.data.SESSION_MAX_AGE; /** - * PostgreSQL connection URL taken from Vercel. + * PostgreSQL connection URL for Prisma taken from Neon. * * @example * 'postgresql://user:password@host:5432/database'; * - * @see https://vercel.com/dashboard/stores - */ -export const POSTGRES_URL = parsed.data.POSTGRES_URL; - -/** - * PostgreSQL connection URL for Prisma taken from Vercel. - * - * @example - * 'postgresql://user:password@host:5432/database'; - * - * @see https://vercel.com/dashboard/stores + * @see https://neon.tech/docs/guides/prisma */ export const POSTGRES_PRISMA_URL = parsed.data.POSTGRES_PRISMA_URL; /** - * Non-pooling PostgreSQL connection URL taken from Vercel. + * Non-pooling PostgreSQL connection URL taken from Neon. * * @example * 'postgresql://user:password@host:5432/database'; * - * @see https://vercel.com/dashboard/stores + * @see https://neon.tech/docs/guides/prisma */ export const POSTGRES_URL_NON_POOLING = parsed.data.POSTGRES_URL_NON_POOLING; /** - * The PostgreSQL user from Vercel. - * - * @example - * 'user'; - * - * @see https://vercel.com/dashboard/stores - */ -export const POSTGRES_USER = parsed.data.POSTGRES_USER; - -/** - * The PostgreSQL password from Vercel. - * - * @example - * 'password'; - * - * @see https://vercel.com/dashboard/stores - */ -export const POSTGRES_PASSWORD = parsed.data.POSTGRES_PASSWORD; - -/** - * The PostgreSQL database from Vercel. - * - * @example - * 'database'; - * - * @see https://vercel.com/dashboard/stores - */ -export const POSTGRES_DATABASE = parsed.data.POSTGRES_DATABASE; - -/** - * The PostgreSQL host from Vercel. - * - * @example - * 'ep-sweet-pineapple.us-east-1.postgres.vercel-storage.com'; - * - * @see https://vercel.com/dashboard/stores - */ -export const POSTGRES_HOST = parsed.data.POSTGRES_HOST; - -/** - * The URL of another PostgreSQL database to shadow. + * The URL of another Neon PostgreSQL database to shadow for migrations. * * @example * 'postgresql://user:password@host:5432/database'; + * + * @see https://neon.tech/docs/guides/prisma-migrate */ export const SHADOW_DATABASE_URL = parsed.data.SHADOW_DATABASE_URL; diff --git a/src/hooks/utilities/useNavbar.ts b/src/hooks/utilities/useNavbar.ts index 474ec92..c718a14 100644 --- a/src/hooks/utilities/useNavbar.ts +++ b/src/hooks/utilities/useNavbar.ts @@ -34,8 +34,8 @@ const useNavbar = () => { /** These pages are accessible to both authenticated and unauthenticated users. */ const otherPages: readonly Page[] = [ - { slug: '/breweries', name: 'Breweries' }, { slug: '/beers', name: 'Beers' }, + { slug: '/breweries', name: 'Breweries' }, ]; /**