Code Monkey home page Code Monkey logo

beerapp-end's Introduction

Documentation

Queries

getCustomer

  • Description: Retrieve details of a customer by ID.
  • Arguments:
    • id: ID of the customer.
      • Type: String
      • Required: Yes
  • Return Type: GetCustomerResponse

Mutations

signup

  • Description: Registers a new user.
  • Arguments:
    • signUpInput: Input data for user registration.
      • Type: SignUpInput
      • Required: Yes
  • Return Type: SignResponse

activate

  • Description: Activate an account by an activation code.
  • Arguments:
    • activationCode: Input data for user activation.
      • Type: ActivationCode
      • Required: Yes
  • Return Type: Boolean

signin

  • Description: Logs in an existing user.
  • Arguments:
    • signInInput: Input data for user login.
      • Type: SignInInput
      • Required: Yes
  • Return Type: SignResponse

logout

  • Description: Logs out a user.
  • Return Type: LogoutResponse

getNewTokens

  • Description: Retrieves new authentication tokens using a refresh token.
  • Arguments:
    • customerId: ID of the customer.
      • Type: String
      • Required: Yes
    • refreshToken: Refresh token for authentication.
      • Type: String
      • Required: Yes
  • Return Type: NewTokensResponse

updateCustomer

  • Description: Updates customer information.
  • Arguments:
    • updateAuthInput: Updated data for customer.
      • Type: UpdateAuthInput
      • Required: Yes
    • customerId: ID of the customer.
      • Type: String
      • Required: Yes
  • Return Type: GetCustomerResponse

deleteCustomer

  • Description: Deletes a customer.
  • Arguments:
    • id: ID of the customer to delete.
      • Type: String
      • Required: Yes
    • customerId: ID of the customer performing the deletion.
      • Type: String
      • Required: Yes
  • Return Type: DeleteCustomerResponse

Examples

mutation SignUp($input:SignUpInput!) {
	signup(signUpInput:$input){
	   accessToken
	   refreshToken
	   customer{email}
  }
}

variables:
{
  "input": {
	   "email" : "[email protected]",
	   "password":"12345"
	}
}
mutation Activate($input:ActivationCode!){
  activate(activationCode:$input)
}

variables:
{
  "input": {
		"activationCode" : "01fe68c5-ccce-45cd-bff4-7a31d7639a74"
	}
}
mutation SignIn($input:SignInInput!){
      signin(signInInput:$input){
		accessToken
	   refreshToken
	   customer{email}
	}
}

variables:
{
  "input": {
	   "email" : "[email protected]",
	   "password":"12345"
	}
}
mutation Logout($id:String!){
   logout(id:$id){loggedOut}
}

variables:
{"id": "302767e2-3d32-4103-adad-2699b61859b2"}
mutation Refresh {
   getNewTokens{accessToken refreshToken}
}

variables:
{"id": "302767e2-3d32-4103-adad-2699b61859b2"}
query getCustomer($id: String!) {
   getCustomer(id: $id){
      id
      email
      role
   }
}

variables:
{"id": "302767e2-3d32-4103-adad-2699b61859b2"}
mutation updateCustomer($input:UpdateAuthInput!) {
   updateCustomer(updateAuthInput:$input){
      id
      email
      role		
   }
}

variables:
{
  "input": {
		"id": "1d68963f-a414-460a-adf4-a8df46ad618d",
	   "email": "[email protected]",
      "role": "USER"
	}
}
mutation deleteCustomer($id:String!) {
	deleteCustomer(id:$id){
      id	
   }
}

variables:
{"id" : "1d68963f-a414-460a-adf4-a8df46ad618d"}
HTTP Header
{"authorization" : "Bearer JWT.Tok.en"}

Node.js recruitment task - senior

This repository contains the base code for recruitment exercise. Complete the tasks listed below and publish the solution on your github. Send us a link to your repository at least 1 day before the interview. We will discuss the proposed solution during the interview. You should be ready to present the working application on your local machine.

There is some key features that must be implemented in the recruitment task:

  • CRUD operations for customers (get, update, delete) by id or email;

  • login and signup operations for customers;

  • roles USER and ADMIN;

  • access token;

  • refresh token;

  • restrict access to get customers operation from unauthenticated users;

  • restrict access to delete customer and update customer operations from unauthenticated users and customers with USER role;

  • ability to verify customer's account after signup with activation code;

Installation

# Install packages
npm install

npx prisma generate

Local database

# Setup local postgres
docker run --name recruitment-task -e POSTGRES_PASSWORD=docker -p 5432:5432 -d postgres:11.16

#create .env file with your local database credentials

# Run migration
npx prisma migrate dev

# Run db seed
npx prisma db seed

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

beerapp-end's People

Contributors

drivesoft 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.