
From Zero to Service, Build with Best Practices, Minimal Code, and Essential Tools
π Read The Docs π
Installing this template automatically sets up the following libraries/tools. By saving you significant effort, it allows you to focus entirely on writing your product code.π€
App | ||||
Tools | ||||
Testing | ||||
Others |
Please read the features provided by this template first! π Challenges Solved
- Node.js v20 or higher
- Docker
When installing the repository, you can skip the setup section, as the init script will do the equivalent of setup.
$ npx create-app-foundation@latest
The CLI creates a project directory and run internal/init script so it's easy to get started.
This repo is a GitHub template, so click the "Use this template" button to create your repo. Then, you need to execute the below to finish setting it up.
$ node .internal/setup/init.mjs
The following items will be asked whether they are required when the project is initialized:
- Sample Application Code
- Dockerfile
- E2E Testing
- Observability feature
- Stripe
# enable corepack
$ npm run setup
# install deps
$ pnpm i
# create ".env" and modify environment variables
$ cp .env.sample .env
$ pnpm dev
-
Create a subscription here and get
price_id
. -
Modify the environment variables. The test API key is here.
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
STRIPE_PRICE_ID=
-
Install stripe CLI to bypass the webhook.
-
Execute the following command in another terminal.
$ stripe listen --forward-to localhost:3000/api/payment/webhook
- After signing in, you can go to the
http://localhost:3000/me/payment
page to see how to make a payment.
$ pnpm db:up
$ pnpm build
$ pnpm start
This template uses Jaeger as a tracing platform. The local environment doesn't require TRACE_EXPORTER_URL
environment value.
# open Jaeger
$ open http://localhost:16686/
$ pnpm test
$ pnpm test:watch
A build task must be executed before running tests to bypass JWT logic.
# install chrome
$ pnpm exec playwright install chrome
# build using test environments since it needs to change encode/decode functions of next-auth
$ pnpm build:test
$ pnpm test:e2e
$ pnpm test:e2e:ui
$ pnpm db:migrate
$ pnpm db:reset
# view the database items
$ pnpm db:studio