项目作者: leadstar116

项目描述 :
Simple referral back-end api based on Nest.js
高级语言: TypeScript
项目地址: git://github.com/leadstar116/nestjs-simple-referral.git
创建时间: 2020-06-24T19:48:13Z
项目社区:https://github.com/leadstar116/nestjs-simple-referral

开源协议:

下载


NestJS Jumpstart

Description

The Problem:
The company wants to implement a customer referral program, in order to acquire new paying customers. Here are the product requirements that we are given:
```● An existing user can create a referral to invite people, via a shareable sign-up link that contains a unique code
● When 5 people sign up using that referral, the inviter gets $10.
● When somebody signs up referencing a referral, that person gets $10 on signup.
Signups that do not reference referrals do not get any credit.
● Multiple inviters may invite the same person. Only one inviter can earn credit for a
particular user signup. An inviter only gets credit when somebody they invited signs up; they do not get credit if they invite somebody who already has an account.

  1. Use cases:
  2. ```● Alice, an existing user, creates a referral. She gets a link that has a unique code in it.
  3. She emails that link to 5 of her friends.
  4. ● Bob, one of Alice’s friends, clicks on the link. He goes through the signup process to
  5. create a new account. Once he has created his account, he sees that he has $10 in
  6. credit.
  7. ● Four more people follow the same process as Bob, clicking on the link Alice sent them.
  8. They all get $10 in credit. Once the fifth person has signed up, Alice sees that she has
  9. $10 in credit.
  10. ● Jeffrey signs up using a link that does not contain a unique referral code. After he
  11. creates a new account, he has $0 in credit.

You can check live swagger ui here: (https://nestjs-referral-staging.herokuapp.com/api)

Installation

  1. $ yarn install

Database configuration

Install postgres latest version. Copy .env.example -> .env and config database variables.

  1. $ yarn migration:run

Running the app

  1. # development
  2. $ yarn start
  3. # watch mode
  4. $ yarn start:dev
  5. # production mode
  6. $ yarn start:prod

Open browser and visit localhost:8080/api.

Test

  1. # unit tests
  2. $ yarn test
  3. # e2e tests
  4. $ yarn test:e2e
  5. # test coverage
  6. $ yarn test:cov