Giter Club home page Giter Club logo

0xa's Introduction

amaris-axa

This project exposes an ExpressJs server that is a proxy to secure, access, and filter any Policy and Client endpoints compatible with mocky.io V2 580891a4100000e8242b75c5 and 5808862710000087232b75ac.

Before you start

The server requires the .env file. Use the example file (.env.example) to configure your environment.
⚠️ Never push your env file into the repository.
Contact your manager to get your test endpoints and the rest of the required parameters.

Once you have the project on your machine, please run the following commands to ensure you have all the required dependencies.

  1. run npm install to donwload all the node modules
  2. make a copy of the .env.example as .env
  3. run npm test

A.P.I.

Routes

GET /v1/users/

  • Require Bearer token via header (see /auth)
  • Can be accessed by users with role "users" and "admin"
  • Can be filtered by name using the querystring ?name=
  • Returns and array of User
  • If no results are available, empty array is returned
export interface User {
  id: string
  name: string
  email: string
  role: Role
}

GET /v1/users/:id

  • Require Bearer token via header (see /auth)
  • Can be accessed by users with role "users" and "admin"
  • Returns the User associated to the give id
  • If no results are available, 404 is returned
  • If no ID is provided, 400 is returned
interface User {
  id: string
  name: string
  email: string
  role: Role
}

GET /v1/users/:id/policies

  • Requires Bearer token via header (see /auth)
  • Can be accessed by users with role "admin" and by the own user
  • Get the list of policies of the given user id
  • If no results are available, 404 is returned
interface Policy {
  id: string
  amountInsured: number
  email: string
  inceptionDate: string
  installmentPayment: boolean
  clientId: string
}

Authentication

GET /auth

  • Requires email via querystring
  • If the client is found, a token is generated
  • If no results are available, 401 is returned
  • Returns a JSON object having the customer data and the new token
{
  access_token: string
  token_type: string  // Bearer
  expires_in: number  // 3600
}

Start the server locally

  1. make sure your project compiles as it should be, run npm run build.
  2. start the server locally, run npm start.
  3. At this point you should see running on 8080 (1 per availabe CPU on your dev machine).

Generate a token

  1. navigate to http://localhost:8080/[email protected].
  2. copy the access_token somewhere (maybe a variable TOKEN)

Get some data

  1. get all the users, using the token generated on the step 5
curl  -H 'Accept: application/json' \
      -H "Authorization: Bearer ${TOKEN}" \
      http://localhost:8080/v1/users

0xa's People

Watchers

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