/__take_home_backend

API project using - Nest Js, GraphQl, MongoDb

Primary LanguageTypeScriptMIT LicenseMIT

Description

Take Home API - backend starter package

Used Tech's

  • Nest JS
  • Mongo
  • Bcrypt
  • JWT
  • GraphQL
  • Class Validator

Installation

$ yarn install

Running the app

# development watch mode
$ yarn start:dev

# production mode
$ yarn start:prod

Resolvers

SIGNIN - Resolver (GraphQl Query)

# For 1 day login access
query {
  signin(
    signin: {
      email: valid email address thats been registered
      password: correct password
      isRemembered: 1
    }
  ) {
    accessToken
    timeout
  }
}

# For 1 hour login access
query {
  signin(
    signin: {
      email: valid email address thats been registered
      password: correct password
      isRemembered: 0
    }
  ) {
    accessToken
    timeout
  }
}

# signin ok response
{
  "data": {
    "signin": {
      "accessToken": one unique generated token containing user email address as payload,
      "timeout": access timeout in utc
    }
  }
}

# signup error response
{
  "errors": [
    {
      "message": any string,
      "locations": array of {line: number, column: number},
      "path": array of string
      "extensions": any error as object
  ],
  "data": any
}

SIGNUP - Resolver (GraphQl Mutation)

# signup request
mutation {
  signup(
    signup: {
      email: valid email address thats never been registered before
      password: any password
    }
  ) {
    id
    email
  }
}

# signup ok response
{
  "data": {
    "signup": {
      "id": "61167993150a3881ad5e8e51",
      "email": "rifat@gmail.com"
    }
  }
}

# signup error response
{
  "errors": [
    {
      "message": any string,
      "locations": array of {line: number, column: number},
      "path": array of string
      "extensions": any error as object
  ],
  "data": any
}

Screenshots

  • Sign In Success sigin-success

  • Sign In (User not found) sigin-user-not-found

  • Sign In (Wrong Password) sigin-wrong-password

  • Sign Up Success sigup-success

  • Sign Up (Wrong Email) signup-wrong-email

  • Sign Up (Email Available) signup-email-available

  • Database Demo database-demo

License

Nest is MIT licensed.