Giter Club home page Giter Club logo

lucky-draw's Introduction

Lucky Draw

Backend system for organizing and participating in a Lucky Draw event. Users can participate in a running event. After the event is over, winner is computed automatically by running a scheduled job, which computes the winner.

Techstack

NodeJs
ExpressJs
Mongodb
ReactJs

Deployed links

Development

For starting frontend React server

  • $ cd _frontend
  • $ npm install
  • $ npm start
  • Visit http://localhost:3000/ from the browser

For running express server

from the root directory

  • $ npm install

  • make a .env file and store database URI string there.

  • $ npm run dev

API documentation for local development

POST : http://localhost:9000/api/get-ticket
POST : http://localhost:9000/api/add-user
POST : http://localhost:9000/api/participate
POST : http://localhost:9000/api/add-event
GET  : http://localhost:9000/api/next-event
GET  : http://localhost:9000/api/last-week-winners
GET  : http://localhost:9000/api/users
GET  : http://localhost:9000/api/running-event

Get Raffle tickets

  • URL:
http://localhost:9000/api/get-ticket
  • Method: -
POST
  • URL PARAMS:
{
    "email":"[email protected]"
}
  • Success Response:
Code:201
Content: {ticket added successfully}
  • Error Response:
Code: 404 NOT FOUND
Content: { error : "User doesn't exist" }

OR

Code: 401 UNAUTHORIZED
Content: { error : "You are unauthorized to make this request." }

Get Next-Upcoming event

  • URL:
http://localhost:9000/api/next-event
  • Method: -
GET
  • URL PARAMS:
None
  • Success Response:
Code:200
Content: {
    "date": "23 April 2021",
    "reward": "lappy",
    "time": "10:59:00 am",
    "eventName": "test-event-9"
}
  • Error Response:
Code: 400 Bad Request
Content: { error : "Bad request" }

OR

Code: 401 UNAUTHORIZED
Content: { error : "There's no Lucky Draw Event" }

Participate in an Event

  • URL:
http://localhost:9000/api/participate
  • Method: -
POST
  • URL PARAMS:
{
    "email":"[email protected]",
    "event":"test-event-8"
}
  • Success Response:
Code:201
Content: {"You participated successfully"}
  • Error Response:
Code: 400 Bad Request
Content: { "You dont have enough tickets to participate" }

OR

Code: 400 Bad Request
Content: { error : "Event not running right now" }

OR

Code: 400 Bad Request
Content: { error : "You already participated, can't participate again" }

Last week event's winner

  • URL:
http://localhost:9000/api/last-week-winners
  • Method: -
GET
  • URL PARAMS:
None
  • Success Response:
Code:200
Content: [
    {
        winner:"[email protected]",
        eventName: "Grofers event"
    }
]
  • Error Response:
Code: 400 Bad Request
Content: { "No Events in the last week"" }

OR


Code: 401 Unauthorized
Content: { error : "Bad request" }

API to add events

  • URL:
http://localhost:9000/api/add-event
  • Method: -
POST
  • URL PARAMS: duration (in mins)
{
    "eventName": "test-event-9",
    "startsAt" : "2021/04/23 10:59:00",
    "duration": 1,
    "reward" : "iPad"
}
  • Success Response:
Code:201
Content: {"Event registered successfully"}
  • Error Response:
Code: 400 Bad Request
Content: { "Event already registered! Can't register again" }

OR

Code: 401 Unauthorized
Content: { error : "Bad request" }

API for getting all the users

  • URL:
http://localhost:9000/api/users
  • Method: -
GET
  • URL PARAMS:
None
  • Success Response:
  • Error Response:
Code: 401 Unthorized
Content: { error : "Bad request" }

API to get the running event

  • URL:
http://localhost:9000/api/running-event
  • Method: -
GET
  • URL PARAMS: NONE

  • Success Response:

Code:201
Content: [{
    "eventName": "test-1",
    "reward": "Laptop",
    "startsAt": "25 April 2021",
    "time": "2:30:00 am"
}]
  • Error Response:
Code: 400 Bad Request
Content: { "There's no running Lucky Draw Event" }

OR

Code: 401 Unauthorized
Content: { error : "Bad request" }

API to add new user

  • URL:
http://localhost:9000/api/add-user
  • Method: -
POST
  • URL PARAMS:
{

"username":"ankit",
"email":"[email protected]"

}
  • Success Response:
Code:201
Content: User saved
  • Error Response:
Code: 401 Unauthorized
Content: { error : "Bad request" }

lucky-draw's People

Contributors

anksus avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.