Skip to content

Latest commit

 

History

History
155 lines (95 loc) · 2.52 KB

README.md

File metadata and controls

155 lines (95 loc) · 2.52 KB

nextjs-template

A template for a Next.js application

Getting Started

Use nvm to use the project's Node version

nvm use

Install dependencies

npm install

Config

Configuration for the application is available within the src/config/index.ts file. See the config file for configuration elements exposed via environment variables.

Database

This project utilizes Prisma for its ORM, and expects a PostgreSQL database instance.

The database schema is stored in the schema.prisma file.

Setup Postgres

Install PostgreSQL and populate the .env.* files with the correct DATABASE_URL string to connect to PostgreSQL.

The DATABASE_URL should be populated as such:

DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/nextjs-template"

Run Migrations

To run migrations:

npm run db:migrate

Create New Migration

To create a new migration (and run it):

npm run db:migrate --name <migration name>

Seeds

Database seeds are found in the seeds script directory.

To run the script to generate seed data:

npm run db:seed

Reset the database, re-run migrations, and re-seed the database:

npm run db:reset

Tests

Lint and Type Checking

This project is configured to use ESLint as the linter.

To run both lint and compile TypeScript files:

npm run lint

Unit Tests

Jest unit tests exist along side the source files.

To run the tests:

npm test

To run tests in watch mode:

npm run test:watch

Integration Tests

Integration tests exist in integration-tests.

The integration tests require a test database. This is setup via Docker Compose, and requires a running Docker instance.

To run the tests:

  • Start Docker (Docker Desktop is an easy option).

  • Start the test database

npm run ci:up
  • Migrate and seed the test database
npm run ci:db:reset
  • Run the tests
npm run test:ci

To run tests in watch mode:

npm run test:ci:watch

When tests are complete, you can shutdown the test database:

npm run ci:down

Code Coverage

To run all the tests and include code coverage, follow the steps above for the specific test types. Then to run the tests:

npm run test:coverage

Storybook

This app uses Storybook to demo UI components.

To run storybook:

npm run storybook