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
- clone this repository
- install all packages needed:
yarn install
- 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:
- Be sure you have docker installed on your system
- 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) - 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. - copy the Pull image from the command line and paste it into a terminal
- 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>
- enjoy io-dev-api-server on
http://127.0.0.1:<YOUR_HOST_PORT>/
IO-App with this server
Run- run the server
yarn start
- 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) - run
yarn postinstall
(update config file injected into the app) - run the app
yarn run-ios
oryarn 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