This repository is a collection of modern web development tools aimed at creating fast, robust, and future-proof applications. These applications are designed to handle complex business domains, utilizing a domain-driven approach and setup to ensure scalability and maintainability. This repository is about:
- Using minimal and well-known libraries
- Writing clean code is a domain driven approach
- Well tested with unit tests and e2e tests
To get started, you need pnpm and docker.
git clone https://github.com/mathi123/neurotic-web.git
cd neurotic-web
pnpm i
pnpm db:start
pnpm db:migrate
And to start the dev server:
pnpm dev
Next.js was installed using manual install procedure. This contains a section on TypeScript setup in VS Code.
The tsconfig file contains settings for compiling TypeScript. The following settings were modified:
- allowJs: set to false
- strict: set to true
In order for @/... imports to work, the following config was added:
"baseUrl": ".",
"paths": {
"@/*": ["app/*"]
}
Commit messages must use the Conventional Commits config.
ESLint was set up to use 3 rule sets:
- Next.js rules
- TypeScript rules
- Prettier rules (such that they don't conflict)
Prettier is used to automatically format code.
The Node.js version is indicated in .npmrc, and the pnpm version in package.json. These versions are also used on CI/CD. Be careful to run commands with pnpm, not your local npm version.
Vitest is used for running unit tests.
pnpm test
# Or with code coverage
pnpm test:coverage
Prisma is used as an ORM. Modify the schema.prisma file, and add a migration as follows:
pnpm db:migrate
Notes:
- Neon Adapter is used on production and Pg Adapter for local development
- To check: connection pooling still relevant with Neon driver?
AuthJs ... About Edge Compatibility
Variable | Description |
---|---|
DATABASE_URL | The database url. |
DATABASE_URL_UNPOOLED | Direct database url, without connection pooling. |
AUTH_SECRET | Used by AuthJS |
This log explains why packages were installed.
Reason | Package(s) |
---|---|
Next.js setup | next@latest, react@latest, react-dom@latest |
commit message linting | @commitlint/config-conventional, @commitlint/cli, husky |
ESLint via Next.js | eslint, eslint-config-next, eslint-config-prettier, @eslint/eslintrc |
validating models | zod |
prisma ORM setup | prisma, @prisma/client, @prisma/adapter-neon, @prisma/adapter-pg |
Unit testing setup | vitest, vite-tsconfig-paths, jsdom, @vitejs/plugin-react, @testing-library/dom, @testing-library/react |
Unit test coverage | @vitest/coverage-v8 |
Authentication | next-auth, @auth/prisma-adapter, bcrypt |
TurboPack and @prisma/pg-adapter don't work well together, for pnpm. The following error is thrown when instantiating the adapter.
Package pg can't be external
The request pg matches serverExternalPackages (or the default list).
The request could not be resolved by Node.js from the project directory.
Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
Try to install it into the project directory by running npm install pg from the project directory.
A temporary fix was to modify the .npmrc file as mentioned here.
public-hoist-pattern[]=*pg*