0.1.3 • Published 2 years ago

@pagopa/io-dev-api-server v0.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

codecov

IO dev API server

It's a simple mock server of io-backend for io-app. It has been created to make the app development process easier and more productive. With this local server the developer can:

  • run it on local machine (no internet connection needed)
  • change response payloads to test and stress the app
  • add new paths and handlers to integrate and test features not yet released
  • understand flows and data exchanged between app and backend

Installation

On macOS and Linux we recommend the use of nodenv for managing multiple versions of NodeJS. The node version used in this project is stored in .node-version.

Setup

  1. clone this repository
  2. install all packages needed: yarn install
  3. you are ready! start the server: yarn start

Commands 2 and 3 should be executed on the first setup and only when io-backend specs change

Docker setup

A docker image is also available for local dev purposes by following these simple steps:

  1. Be sure you have docker installed on your system
  2. login into the github packages registry by running docker login -u <YOUR_GITHUB_USERNAME> -p <GITHUB_TOKEN> docker.pkg.github.com (The configuration is pretty simple and fast, you can follow these instructions)
  3. point your browser to: https://github.com/pagopa/io-dev-api-server/packages and choose the package version (namely <CHOSEN_PACKAGE_VERSION>) you are looking for. Please note that latest version is recommended.
  4. copy the Pull image from the command line and paste it into a terminal
  5. after docker daemon finish to download image run this command: docker run -d -p <YOUR_HOST_PORT>:3000 docker.pkg.github.com/pagopa/io-dev-api-server/io-dev-api-server:<CHOSEN_PACKAGE_VERSION>
  6. enjoy io-dev-api-server on http://127.0.0.1:<YOUR_HOST_PORT>/

Run IO-App with this server

  1. run the server yarn start
  2. in the app project folder run cp .env.local .env (it is configured with a server running in the same machine of the device. You can edit the server endpoint on your needs)
  3. run yarn postinstall (update config file injected into the app)
  4. run the app yarn run-ios or yarn run-android

you could edit the server port (serverPort - default is 3000)

Login

The current login implementation by-passes SPID authentication: when the user asks for a login with a certain SPID Identity Provider, the server responses with a redirect containing the session token. The user will be immediately logged in.

Session

When the client asks for a session, a valid session is always returned. Of course the developer could implement a logic to return an expired session response to test different scenarios.

Profile

The profile is mocked (hard-coded). If you want the server reponses a different profile, just edit it! On upsert profile request the server acts like a mirror: it gives back the updated profile (sent by the client) increasing the profile version