A template for a Next.js application
Use nvm to use the project's Node version
nvm use
Install dependencies
npm install
Configuration for the application is available within the src/config/index.ts
file. See the config file for configuration elements exposed via environment variables.
This project utilizes Prisma for its ORM, and expects a PostgreSQL database instance.
The database schema is stored in the schema.prisma file.
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"
To run migrations:
npm run db:migrate
To create a new migration (and run it):
npm run db:migrate --name <migration name>
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
This project is configured to use ESLint as the linter.
To run both lint and compile TypeScript files:
npm run lint
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 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
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
This app uses Storybook to demo UI components.
To run storybook:
npm run storybook