Skip to content

phearoak/Area

Repository files navigation

Area 51

How to Setup

  • Copy environment variables. Replace values to your own.
cp .env.example .env
docker-compose build
  • Start containers.
docker-compose up --detach

How to contribute

Add a service

  1. Create a file with service name in src/connectors folder which extends from Connector and implements IConnector
  2. Implement the authenticate method which takes the code returned by the oauth as a parameter and returns the access_token
  3. Next, you have to create two functions in ConnectorController (src/controllers/ConnectorController.ts)
    • First, create a function that returns the oauth url of the service
    • The second function is an express controller which allows you to retrieve the queries, validate them and send the code in the authenticate function implemented previously
  4. Finally add and modify these two lines in the file src/routes/connector.route.ts
router.get("/<service_name>", isAuthenticated, ConnectorController.<first_function_name>);
router.get("/<service_name>/authorize", ConnectorController.<second_function_name>);
  1. In order for the oauth call to work, the redirect_uri parameter must be the route that calls the controller (second function, here: /<service_name>/authorize)

Add an action

  1. To add an action, you must first create a service.
  2. In src/prisma/seeder.ts, add a function which add a function which is called in main, in it create the action (refer to other functions for implementation). Change name to the name of the webhook event.
  3. Create fields for the action (fields are the inputs you ask the user for when choosing the action).
  4. If you want populate a select. for example, to select values ​​retrieved via the API, add a field_<field_name> method in the connector. this method takes an array of Field. Refer to the GitHub.ts file to implement the logic.
  5. Next, open the associated service file in the src/connectors folder
  6. Implement the webhook function. This one takes in parameter workflow_id which is a number, event which is a string and a payload.
async webhook(workflow_id: number, event: string, payload?: Object)
  1. workflow_id is the id of the previously created workflow which must be added in the url that the webhook must call.
  2. event is the name of the event.
  3. payload is an object that includes previously created fields.
  4. In the webhook method, call the api route of the service to which you want to add the action and put as url:
${host}/workflow/callback/${workflow_id}

Add a reaction

  1. To add a reaction, you must first create a service.
  2. In src/prisma/seeder.ts, add a function which add a function which is called in main, in it create the reaction (refer to other functions for implementation). Set the name that you want.
  3. Create fields for the action (fields are the inputs you ask the user for when choosing the reaction).
  4. If you want populate a select. for example, to select values ​​retrieved via the API, add a field_<field_name> method in the connector. this method takes an array of Field. Refer to the GitHub.ts file to implement the logic.
  5. Next, open the associated service file in the src/connectors folder
  6. Implement the method with the name you choose. This one takes a payload which is an object with all fields.
  7. Finally, implement the logic of the reaction in this method.

Diagram

Diagram

Stack ⚡

    stack: [
        "nodejs",
        "typescript",
        "express",
        "prisma",
        "mysql",
        "reactjs",
        "react-native"
    ];

API Endpoints

About

Method URL Description
GET /about.json about.json

Auth

Method URL Description
POST /auth/signup Sign up an account
POST /auth/signin Sign in to an account

Service

Method URL Description
POST /service Create a service
GET /service/:id Get a service
PATCH /service/:id Update a service
DELETE /service/:id Delete a service

Action

Method URL Description
GET /action/:id/fields Get action's fields
POST /action/:service Create an action
GET /action/:service/:id Get an action
PATCH /action/:service/:id Update an action
DELETE /action/:service/:id Delete an action

Reaction

Method URL Description
GET /reaction/:id/fields Get reaction's fields
POST /reaction/:service Create a reaction
GET /reaction/:service/:id Get a reaction
PATCH /reaction/:service/:id Update a reaction
DELETE /reaction/:service/:id Delete a reaction

Workflow

Method URL Description
POST /workflow Create a workflow
GET /workflow/:id Get a workflow
PATCH /workflow/:id Update a workflow
DELETE /workflow/:id Delete a workflow
GET /workflow/callback/:id Callback a workflow

Token

Method URL Description
POST /token/:service Create a token
GET /token/:id Get a token
PATCH /token/:id Update a token
DELETE /token/:id Delete a token

Field

Method URL Description
POST /field/ Create a field
GET /field/:id Get a field
PATCH /field/:id Update a field
DELETE /field/:id Delete a field
Matthéo Selingant
Matthéo Selingant
Basile Lamotte
Basile Lamotte
Tom Bartuzel
Tom Bartuzel
Phearoak Em
Phearoak Em
Evan Delagnes
Evan Delagnes

About

Automation platform of his digital life

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors