Git Product home page Git Product logo

saloon-server's Introduction

Install dependecies

go get github.com/labstack/echo
go get github.com/dgrijalva/jwt-go
go get github.com/joho/godotenv
go get github.com/graphql-go/graphql
go get github.com/go-sql-driver/mysql
go get github.com/jinzhu/gorm
  • Using Echo middleware framework

https://github.com/labstack/echox/tree/master/cookbook/jwt

curl -X GET  localhost:3000/hello

Registration end point

curl -X POST -d "[email protected]&password=password1234&contactNo=91450518" localhost:3000/api/register -H "Content-Type: application/x-www-form-urlencoded"

curl -X POST -d "[email protected]&password=password1234&contactNo=91450516" localhost:3000/api/register -H "Content-Type: application/x-www-form-urlencoded"

curl -X POST -d "[email protected]&password=password1234&contactNo=91450519" localhost:3000/api/register -H "Content-Type: application/x-www-form-urlencoded"

Login end point

curl -X POST -d "[email protected]&password=password1234" localhost:3000/api/login -H "Content-Type: application/x-www-form-urlencoded"

curl -X POST -d "[email protected]&password=password1234" localhost:3000/api/login -H "Content-Type: application/x-www-form-urlencoded"

Common end point to access the database record

curl -X POST localhost:3000/api/restricted -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6dHJ1ZSwiZXhwIjoxNTQyNTI4MTMyLCJuYW1lIjoiYnVubnlwcGxAZ21haWwuY29tIn0.K0NOmo2uEd10iKkhEy16gbPfZVfkT9KPLGVyXf7bkm4"
curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6dHJ1ZSwiZXhwIjoxNTQyNTI4MTMyLCJuYW1lIjoiYnVubnlwcGxAZ21haWwuY29tIn0.K0NOmo2uEd10iKkhEy16gbPfZVfkT9KPLGVyXf7bkm4" -X POST -d '{ query: User(id: "1") { id, firstname, lastname }}' http://localhost:3000/api/restricted

An identifier may be exported to permit access to it from another package. An identifier is exported if both:

Graphql

Get user by id

{
  query: User(id: "1") {id, firstname, lastname, email, isAdmin, createdAt,
  	updatedAt, contactNo, password, hairloss_treatment_cnt, treatment_cnt, cutCnt,
  expiry_date, ptsBalance}
}

{
  query: User(id: "3") {id, firstname, lastname, email, isAdmin, createdAt,
  	updatedAt, contactNo, password, hairloss_treatment_cnt, treatment_cnt, cutCnt,
  expiry_date, ptsBalance}
}

Create user's point

mutation {
  createUserPts(userId: "1", allocatedPts: "11", productId: "3") {
    userId
    allocatedPts
    productId
  }
}

Create product

mutation {
  createProduct(userId: 1, allocatedPts: 11, productId: 3) {
    userId
    allocatedPts
    productId
  }
}

Get all user' points

{
  query: UserPtsHistory(dummy: "") {id, userId, productId, allocatedPts}
}

Update product

mutation {
  updateUserPts(id: "12", userId: "3", allocatedPts: "11", productId: "232") {
    id
    userId
    allocatedPts
    productId
  }
}

saloon-server's People

Contributors

kenken64 avatar nedu76 avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

farablanco

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.