Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/srijanmukherjee/paywall-demo
Demonstration of a credit system
https://github.com/srijanmukherjee/paywall-demo
backend credit-system expressjs paywall stripe
Last synced: 9 days ago
JSON representation
Demonstration of a credit system
- Host: GitHub
- URL: https://github.com/srijanmukherjee/paywall-demo
- Owner: srijanmukherjee
- License: mit
- Created: 2023-11-28T18:39:24.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2023-11-30T14:20:32.000Z (12 months ago)
- Last Synced: 2023-11-30T21:35:31.452Z (12 months ago)
- Topics: backend, credit-system, expressjs, paywall, stripe
- Language: TypeScript
- Homepage:
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Demonstration of a paywall using expressjs
## Running instruction
### Development Mode
```sh
# install dependencies
yarn# Run the server
yarn dev# Start stripe local listener
stripe listen --forward-to localhost:8000/webhook
```## Environment variables
```shell
# Server settings
NODE_ENV=development
SERVER_PORT=8000
HOST=http://127.0.0.1:8000RESEND_API_KEY=
MONGO_CONNECTION_URI="mongodb://root:toor@localhost:27017/paywall_demo?authSource=admin"# Run the command `openssl rand -base64 60`
JWT_TOKEN_SECRET=
JWT_EXPIRE=1h# Stripe API settings
STRIPE_SECRET_KEY=
# generated by stripe listen --forward-to localhost:8000/webhook (in test environment)
STRIPE_WEBHOOK_SECRET=whsec_...
```## Endpoints
| method | endpoint | description |
| ------ | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| GET | `/` | test endpoint |
| POST | `/signup` | user registration |
| POST | `/login` | login user |
| GET | `/account` | get logged in user details |
| GET | `/verify-account/:token` | Email verification |
| PUT | `/account/password` | Reset password for authenticated user |
| GET | `/account/credits` | Get available credits |
| GET | `/packages` | Get available credit packages that can be bought |
| POST | `/packages` | Create a new credit package |
| POST | `/packages/buy` | Buy a credit package |
| GET | `/packages/transactions` | Get all credit purchase transactions |
| GET | `/packages/transactions/:id` | Get more information about a particular credit purchase transaction (TODO) |
| GET | `/resources` | Fetch all resources |
| POST | `/resources` | Create new resource |
| GET | `/resources/:id` | Fetch a particular resource. If it's a paid resource, resource data will be shown only if user has bought the resource |
| POST | `/resources/:id/buy` | Buy a resource |
| GET | `/transactions` | Fetch all resource transactions for a user |
| POST | `/webhook` | Stripe webhook endpoint |