Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pay-as-you-go/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Database Configuration
# PostgreSQL connection string for Drizzle ORM
# Example: postgresql://user:password@localhost:5432/dbname
DATABASE_URL=postgresql://user:password@localhost:5432/dbname

# BetterAuth Configuration
# Secret key for BetterAuth session encryption
# Generate with: openssl rand -base64 32
BETTER_AUTH_SECRET=your-secret-key-here

# Application Configuration (Optional)
# Base URL for the application (used for auth callbacks)
# Defaults to http://localhost:3000 if not set
NEXT_PUBLIC_BASE_URL=http://localhost:3000

# Server Port (Optional)
# Defaults to 3000 if not set
PORT=3000

# Flowglad Configuration
# Secret key for Flowglad billing and subscription management
# Get your secret key from: https://app.flowglad.com/settings
FLOWGLAD_SECRET_KEY=sk_test_your_secret_key_here
144 changes: 144 additions & 0 deletions pay-as-you-go/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier', 'import', 'unused-imports'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/recommended',
'plugin:import/typescript',
'next/core-web-vitals',
'prettier'
],
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
project: './tsconfig.json'
},
settings: {
'import/resolver': {
typescript: true
}
},
rules: {
// Prettier integration
'prettier/prettier': 'error',

// STRICT TYPESCRIPT RULES - No any usage / unsafe any flows
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',

// No type assertions (as/<>). Prefer proper narrowing.
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'never'
}
],
'@typescript-eslint/no-non-null-assertion': 'error',

// Additional strict rules
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/no-unchecked-indexed-access': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',

// Prevent common mistakes
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', ignoreRestSiblings: true }
],
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/prefer-includes': 'error',

// Code quality and boundaries
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',

// Consistency rules
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', fixStyle: 'separate-type-imports', disallowTypeAnnotations: false }
],
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'ban',
'ts-nocheck': 'ban',
'ts-check': 'ban',
'ts-expect-error': 'allow-with-description',
minimumDescriptionLength: 3
}
],
'@typescript-eslint/ban-types': [
'error',
{
extendDefaults: true,
types: {
'{}': {
message: 'Use a more specific type or Record<string, unknown>',
fixWith: 'Record<string, unknown>'
}
}
}
],

// Import hygiene
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
['parent', 'sibling', 'index']
],
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true }
}
],
'import/newline-after-import': 'error',

// Remove unused imports cleanly
'unused-imports/no-unused-imports': 'error',

// General ESLint rules
'no-console': ['error', { allow: ['warn', 'error'] }],
eqeqeq: 'error',
'no-throw-literal': 'error',
'no-debugger': 'error',
'no-alert': 'error',
'no-var': 'error',
'prefer-const': 'error',
'no-unused-expressions': 'error'
},
overrides: [
{
files: ['*.test.ts', '*.test.tsx', '*.spec.ts', '*.spec.tsx'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-console': 'off'
}
}
]
};
98 changes: 98 additions & 0 deletions pay-as-you-go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Dependencies
node_modules/

# Build outputs
dist/
build/
out/
.next/
.nuxt/
.vuepress/dist/

# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# IDE and editor files
.vscode/
.idea/
*.swp
*.swo
*~

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Coverage directory used by tools like istanbul
coverage/
*.lcov

# nyc test coverage
.nyc_output

# Dependency directories
jspm_packages/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# Temporary folders
tmp/
temp/

# Package managers - ALWAYS use bun in this project
package-lock.json
yarn.lock
pnpm-lock.yaml
8 changes: 8 additions & 0 deletions pay-as-you-go/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false
}
22 changes: 22 additions & 0 deletions pay-as-you-go/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2025 Flowglad Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Loading