Modern Node.js backend built with Express, TypeScript, Prisma, and integrated with Stripe and Kinde authentication.
- Express.js with TypeScript for robust API development
- Prisma ORM for database management and migrations
- Stripe Integration for payment processing and webhooks
- Kinde Authentication for secure user management
- Swagger Documentation for API exploration
- Rate Limiting and security middleware
- Comprehensive Logging with Pino
- Jest Testing with coverage reports
- ESLint + Prettier for code quality
- Copy environment variables:
cp .env.example .env-
Fill in the required environment variables in
.env -
Install dependencies:
yarn install- Generate Prisma client:
yarn prisma:generate- Run database migrations:
yarn prisma:migrate- Start the development server:
yarn start:devThe API will run on http://localhost:3001
- Swagger UI: http://localhost:3001/swagger
- API Endpoints: All endpoints are prefixed with
/api
Configure your Kinde application and set the environment variables:
AUTH_URL- Your Kinde public URLKINDE_CLIENT_ID- Kinde client IDKINDE_CLIENT_SECRET- Kinde client secretKINDE_ISSUER_URL- Kinde issuer URLKINDE_SITE_URL- Your site URLKINDE_POST_LOGOUT_REDIRECT_URL- Post logout redirect URLKINDE_POST_LOGIN_REDIRECT_URL- Post login redirect URL
For M2M authentication, enable Kinde Management APIs and configure the appropriate scopes.
STRIPE_SECRET_KEY=sk_test_... # Stripe secret key
STRIPE_WEBHOOK_SECRET=whsec_... # Webhook secret
SUCCESS_URL=http://localhost:3000/success # Success redirect URL
CANCEL_URL=http://localhost:3000/cancel # Cancel redirect URL
PRODUCT_ID1=prod_... # First product ID
PRODUCT_PRICE1=price_... # First product price ID
PRODUCT_ID2=prod_... # Second product ID
PRODUCT_PRICE2=price_... # Second product price ID- Go to Stripe Webhooks
- Add endpoint:
http://localhost:3001/api/payments/webhook - Select events:
checkout.session.completed,payment_intent.succeeded - Copy the webhook secret to
STRIPE_WEBHOOK_SECRET
# Install Stripe CLI
brew install stripe/stripe-cli/stripe
# Login to Stripe
stripe login
# Start webhook listener
stripe listen --forward-to http://localhost:8000/api/v1/payments/webhook
# Copy the webhook secret from the outputDATABASE_URL="postgresql://dev:devPassword@db:5432/postgres?schema=public"# Generate Prisma client
yarn prisma:generate
# Create a new migration
yarn prisma migrate dev --name migration_name
# Apply migrations
yarn prisma:migrate
# Deploy migrations (production)
yarn prisma:deploy
# Open Prisma Studio
yarn prisma:studio# Run all tests
yarn test
# Run tests in watch mode
yarn test:watch
# Run tests with coverage
yarn test:coverage# Lint code
yarn lint
# Fix linting issues
yarn lint:fix
# Type check
yarn type-checkyarn start- Start production serveryarn start:dev- Start development server with hot reloadyarn build- Build TypeScriptyarn test- Run testsyarn test:watch- Run tests in watch modeyarn test:coverage- Run tests with coverageyarn lint- Lint codeyarn lint:fix- Fix linting issuesyarn type-check- TypeScript type checkingyarn prisma:generate- Generate Prisma clientyarn prisma:migrate- Run database migrationsyarn prisma:deploy- Deploy migrations (production)yarn prisma:studio- Open Prisma Studio
b4f/
├── src/
│ ├── api/ # API routes and controllers
│ ├── config/ # Configuration files
│ ├── db/ # Database configuration
│ ├── logger/ # Logging utilities
│ └── swagger/ # Swagger documentation
├── prisma/ # Prisma schema and migrations
├── test/ # Test files
├── src/index.ts # Main application entry point
└── package.json
# Build and start with Docker Compose
docker compose up --build b4f
# Run migrations in container
docker compose exec b4f yarn prisma migrate dev
# Generate Prisma client in container
docker compose exec b4f yarn prisma:generate- Rate Limiting - Prevents API abuse
- Helmet - Security headers
- CORS - Cross-origin resource sharing
- Input Validation - Request validation
- JWT Verification - Secure token handling
- Webhook Verification - Stripe webhook security
- Structured Logging with Pino
- Request/Response Logging with Pino HTTP
- Error Tracking and exception handling
- Performance Monitoring capabilities