Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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:8000

RESEND_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 |