Giter Site home page Giter Site logo

fiat-connect-api-example's Introduction

fiatconnect-api-starter

This repository contains a starter API that supports the FiatConnect standard.

Usage

Installing

yarn install

Building

yarn build

Configuring

You can configure the server either with command line arguments, or through a .env file in the repository root. See .env.example for an example. Check out src/config.ts for an exhaustive list of configuration options.

Running

Assuming you've filled in a .env file in the repository root, run:

yarn start

Testing

Unit tests

You can run unit tests with jest as follows:

yarn test

Integration tests

Integration tests are not included with this starter project. However, an example of how to create a Sign-In with Ethereum message for authentication is included in scripts/example-request.ts.

Structure & Schema Validation

Handlers for each of the four main groups of endpoints can be found in /src/routes. To make implementation easy, almost all request schema validation is taken care of in middleware before the handlers are called. Individual endpoint handlers will have access to type-guarded request parameters, guaranteed to be syntactically correct. (Checks on request semantics are still up to the implementor themselves.) This means that you can immediately start implementing business logic within the handlers, without worrying about validation.

The only exception to this is with endpoints whose request bodies are negotiable, i.e., POST /accounts/:fiatAccountSchema and POST /kyc/:kycSchema. Since the request body can take many different shapes, schema validation & type guarding must be performed within the route. In both cases, switch statements are included in the handlers which perform validation and type guarding. Implementors just need to write custom handling logic for each possible schema.

fiat-connect-api-example's People

Contributors

renovate[bot] avatar cajubelt avatar satish-ravi avatar jophish avatar oademid2 avatar lisaqyli 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.