Welcome to the Virtuella API documentation. This API is built using ExpressJS and MongoDB and serves as the backend for the Virtuella project. Below you'll find detailed information on how to interact with the various endpoints provided by the API.
Virtuella API is a RESTful service that provides various endpoints to manage users, employees, and their respective operations. This API is part of the Virtuella project and is called by project's front.
To install and run the API locally, follow these steps:
- Clone the repository:
git clone <repository_url>
- Navigate to the project directory:
cd virtuella-api - Install the dependencies:
npm install
- Set up the environment variables by modifing the
.envfile provided.
To start the API server, use the following command:
npm run startThe server will start on the port specified in the environment variables. By default, it runs on port 3000.
To ensure the API is functioning correctly, you can use both Swagger and cURL requests for testing.
Swagger provides an interactive interface to test API endpoints and view documentation. You can access the Swagger UI for this API at:
http://localhost:3000/
Navigate to this URL in your web browser to view all available endpoints, along with detailed information on request parameters and responses. You can also make test requests directly from the Swagger interface.
For command-line testing, you can use cURL to interact with the API. Be aware that for most of the routes, you'll need a Json Web Token provided with the routes (cf route):
- POST
/login/client - POST
/login/employe
When you have the token, don't forget to add the header Authorization: Bearer + <token>.
Below are some examples of cURL requests you can use to test various endpoints:
-
GET Request
curl -X GET "http://localhost:3000/your-endpoint" -H "accept: application/json"
-
POST Request
curl -X POST "http://localhost:3000/your-endpoint" -H "accept: application/json" -H "Content-Type: application/json" -d '{"key1":"value1","key2":"value2"}'
-
PUT Request
curl -X PUT "http://localhost:3000/your-endpoint/1" -H "accept: application/json" -H "Content-Type: application/json" -d '{"key1":"updatedValue"}'
-
DELETE Request
curl -X DELETE "http://localhost:3000/your-endpoint/1" -H "accept: application/json"
Using these methods, you can comprehensively test the API to ensure it behaves as expected.
- GET /users/ - Retrieve all users (clients and employees).
- GET /users/operations - Retrieve all clients operations.
- GET /users/client - Retrieve client details.
- GET /users/client/:id - Retrieve client details by client ID.
- GET /users/employe - Retrieve all employees.
- GET /users/employe/:id - Retrieve employee details by employee ID.
- POST /send-email - Send a contact email to the employees.
{
"subject": "Subject of email",
"text": "Text format of email",
"html": "HTML format of email"
}-
POST /login/forgotpassword - Forgot password process.
The forgot password process takes place in two steps:
{ "username": "example@domain.com", "type": "clients" }Then you will recieve an email containing an OTP code
{ "username": "client@example.com", "password": "newPassw0rd", "otp": "1234", "type": "clients" } -
POST /login/client - Client login with credentials.
{ "username": "example@domain.com", "password": "password123" } -
POST /login/employe - Employee login with credentials.
{ "username": "0000000000", "password": "password123" } -
POST /users/client/new - Create a new client.
-
{ "email": "client@example.com", "name": "John", "surname": "Doe", "password": "password123" } -
POST /users/employe/new - Create a new employee.
{ "email": "employee@example.com", "name": "Jane", "surname": "Doe", "password": "password123", "role": "ADMIN", "clients": ["client_id_1", "client_id_2"] } -
POST /users/client/virement - Perform a virement operation.
{ "from_iban": "FR0193717749601196862485542", "to_iban": "FR76virt4z5grd6z2szg8e5", "amount": 100, "libelle": "Rent Payment" } -
POST /users/client/new/card - Create a new card for a client.
{ "ident": "client_id", "name": "Visa" } -
POST /users/client/new/account - Create a new account for a client.
{ "ident": "client_id", "name": "Savings" }
- DELETE /users/client/:id - Delete a client by ID.
- DELETE /users/client/beneficiaire/:id - Delete the IDth beneficiaire of the logged in client.
- DELETE /users/employe/:id - Delete an employee by ID.
-
PUT /users/client/:id - Update client details.
{ "surname": "UpdatedSurname", "name": "UpdatedName", "email": "updatedemail@example.com", "accounts": ["account_id_1", "account_id_2"], "cards": ["card_id_1", "card_id_2"] } -
PUT /users/client/account/:id - Update account details.
{ "name": "UpdatedName", "iban": "UpdatedIban" } -
PUT /users/client/beneficiaire/:id - Update client beneficiaires.
{ "name": "NewBeneficiaireName", "surname": "NewBeneficiaireSurname", "iban": "NewBeneficiaireIban", "account": "NewBeneficiaireAccountName" } -
PUT /users/employe/:id - Update employee details.
{ "surname": "UpdatedSurname", "name": "UpdatedName", "email": "updatedemail@example.com", "role": "ADMIN", "clients": ["client_id_1", "client_id_2"] }
Firstly first, thanks to all the contributors:
- Jean-Baptiste Beck Main developer of the API
- Corentin Bouijoux Main developer of the front-end
We welcome contributions to improve the Virtuella API. To contribute, please follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes and commit them:
git commit -m "Add your commit message" - Push to the branch:
git push origin feature/your-feature-name
- Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for more information.
For further details, please refer to the in-code comments and the provided examples in the codebase. If you have any questions or issues, feel free to open an issue in the repository.