Update README and env to mention Neon PG

This commit is contained in:
Aaron William Po
2023-05-14 14:57:19 -04:00
parent 50c3e1a82b
commit 60e76089f3
3 changed files with 21 additions and 75 deletions

View File

@@ -5,7 +5,7 @@
The Biergarten App is a web application designed for beer lovers to share their favorite The Biergarten App is a web application designed for beer lovers to share their favorite
brews and breweries with like-minded people online. 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. 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 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/) - [Prisma](https://www.prisma.io/)
- An open-source ORM for Node.js and TypeScript applications. - An open-source ORM for Node.js and TypeScript applications.
- [Vercel Postgres](https://vercel.com/dashboard/stores) - [Neon Postgres](https://neon.tech/)
- A managed PostgreSQL database service provided by Vercel. - A managed PostgreSQL database service powered by Neon.
- [Cloudinary](https://cloudinary.com/) - [Cloudinary](https://cloudinary.com/)
- A cloud-based image and video management service that provides developers with an easy - A cloud-based image and video management service that provides developers with an easy
way to upload, store, and manipulate media assets. 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) - [Cloudinary](https://cloudinary.com/users/register/free)
- [SparkPost](https://www.sparkpost.com/) - [SparkPost](https://www.sparkpost.com/)
- [Vercel Postgres](https://vercel.com/dashboard/stores) - [Neon Postgres](https://neon.tech/)
- [Mapbox](https://account.mapbox.com/auth/signup/) - [Mapbox](https://account.mapbox.com/auth/signup/)
### Setup ### Setup
@@ -126,13 +126,11 @@ SESSION_SECRET=
SESSION_TOKEN_NAME= SESSION_TOKEN_NAME=
SESSION_MAX_AGE= SESSION_MAX_AGE=
NODE_ENV= NODE_ENV=
POSTGRES_URL=
POSTGRES_PRISMA_URL= POSTGRES_PRISMA_URL=
POSTGRES_URL_NON_POOLING= POSTGRES_URL_NON_POOLING=
POSTGRES_USER= SHADOW_DATABASE_URL=
POSTGRES_HOST=
POSTGRES_PASSWORD=
POSTGRES_DATABASE=
MAPBOX_ACCESS_TOKEN= MAPBOX_ACCESS_TOKEN=
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN= NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=
SPARKPOST_API_KEY= SPARKPOST_API_KEY=
@@ -156,10 +154,11 @@ SPARKPOST_SENDER_ADDRESS=" > .env
- You can set this to `biergarten`. - You can set this to `biergarten`.
- `SESSION_MAX_AGE` is the maximum age of the session cookie in milliseconds. - `SESSION_MAX_AGE` is the maximum age of the session cookie in milliseconds.
- You can set this to `604800000` (1 week). - You can set this to `604800000` (1 week).
- `POSTGRES_URL`, `POSTGRES_PRISMA_URL`, `POSTGRES_URL_NON_POOLING`, `POSTGRES_USER`, - `POSTGRES_PRISMA_URL`is a pooled connection string for your Neon Postgres database.
`POSTGRES_HOST`, `POSTGRES_PASSWORD`, and `POSTGRES_DATABASE` are the credentials for - `POSTGRES_URL_NON_POOLING` is a non-pooled connection string for your Neon Postgres database used for migrations.
your Vercel Postgres database. - `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://vercel.com/dashboard/stores). - 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 - `MAPBOX_ACCESS_TOKEN` and `NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN` are the access tokens for
your Mapbox account. your Mapbox account.
- You can create a free account [here](https://account.mapbox.com/auth/signup/). - 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/). - 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. - `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 ```bash
npx prisma generate npx prisma generate

View File

@@ -19,13 +19,8 @@ const envSchema = z.object({
SESSION_TOKEN_NAME: z.string(), SESSION_TOKEN_NAME: z.string(),
SESSION_MAX_AGE: z.coerce.number().positive(), SESSION_MAX_AGE: z.coerce.number().positive(),
POSTGRES_URL: z.string().url(),
POSTGRES_PRISMA_URL: z.string().url(), POSTGRES_PRISMA_URL: z.string().url(),
POSTGRES_URL_NON_POOLING: 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(), SHADOW_DATABASE_URL: z.string().url(),
NODE_ENV: z.enum(['development', 'production', 'test']), 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; 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 * @example
* 'postgresql://user:password@host:5432/database'; * 'postgresql://user:password@host:5432/database';
* *
* @see https://vercel.com/dashboard/stores * @see https://neon.tech/docs/guides/prisma
*/
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
*/ */
export const POSTGRES_PRISMA_URL = parsed.data.POSTGRES_PRISMA_URL; 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 * @example
* 'postgresql://user:password@host:5432/database'; * '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; export const POSTGRES_URL_NON_POOLING = parsed.data.POSTGRES_URL_NON_POOLING;
/** /**
* The PostgreSQL user from Vercel. * The URL of another Neon PostgreSQL database to shadow for migrations.
*
* @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.
* *
* @example * @example
* 'postgresql://user:password@host:5432/database'; * 'postgresql://user:password@host:5432/database';
*
* @see https://neon.tech/docs/guides/prisma-migrate
*/ */
export const SHADOW_DATABASE_URL = parsed.data.SHADOW_DATABASE_URL; export const SHADOW_DATABASE_URL = parsed.data.SHADOW_DATABASE_URL;

View File

@@ -34,8 +34,8 @@ const useNavbar = () => {
/** These pages are accessible to both authenticated and unauthenticated users. */ /** These pages are accessible to both authenticated and unauthenticated users. */
const otherPages: readonly Page[] = [ const otherPages: readonly Page[] = [
{ slug: '/breweries', name: 'Breweries' },
{ slug: '/beers', name: 'Beers' }, { slug: '/beers', name: 'Beers' },
{ slug: '/breweries', name: 'Breweries' },
]; ];
/** /**