Automata testing and validating API for FAVA platform.
Before you begin, make sure you have the following prerequisites installed on your system:
- Node.js (version 12 or higher)
- Node.JS package manager (yarn or npm)
- PostgreSQL server
First, clone the fava-api repository to your local machine. Open a terminal and run the following command:
git clone https://github.com/joaobb/fava-api.git
This command will create a local copy of the repository on your machine.
Navigate to the project directory by running the following command:
cd fava-api
Once inside the project directory, use Yarn to install the required dependencies. Run the following command:
yarn
Using npm:
npm install
This will download and install all the necessary Node.js modules specified in the package.json
file.
This API requires a PostgreSQL database server, that could be created using Docker, for example.
If you choose to use Docker, follow these steps to set up a PostgreSQL container:
Install Docker on your machine by following the official Docker installation guide for your operating system.
Open a terminal and run the following command to start a PostgreSQL container:
docker run --name fava-postgres -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres
This command will create a new PostgreSQL container named fava-postgres with the specified password (mysecretpassword). The container will be accessible on port 5432.
Now run the following command and then replace its variables values to match with your database configuration:
cp .env.example .env
Get yourself a API key from Extended Class.
This will be need for storaging automata payloads.
After creating it, paste its result on .env's EXTENDS_CLASS_API_KEY
To help hash users passwords and make it database storable a JWT secret is needed.
To create it, run the following command and paste its result on .env's JWT_SECRET
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
To create a admin account and have full access of the system, you must set .env's ADMIN_EMAIL
and ADMIN_PASSWORD
with the wanted email and password.
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
To run the migrations, use the following commands:
yarn migrate:generate
yarn migrate:run
This command will create the necessary database tables.
To seed the initial data, run the following command:
yarn seed
This will populate the database with some sample data.
Finally, you can start the fava-api server by running the following command:
yarn dev
This command will start the development server and make the API accessible at the specified port (usually http://localhost:8080
).
Congratulations! You have successfully set up and started the fava-api. You can now start making requests to the API and use it for your desired purposes.