1.0.0 • Published 11 months ago

erised-microservice v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

Description

This is a fast deployment / easy-to-use Node.js server.

Commit Rules & Review

The commits must follow the rules specified in the doitmentation, in order to be accepted for merging.

Installation & Execution

npm i

npm run dev

Runs the server in the development mode.

=======================================================================================================

API Endpoints

Informations about microservice's endpoints

/getAll (GET)

This enndpoint is located inside multiple controllers. Used for mqtt sync. Return all records of a collection.

/users

/register (POST)

Creates a user record based on request's input. Includes validation. Return userId

Data Example

{
    "userId": "f0ea4e43-545c-4f8f-8c2a-6fe5af1c48c5",
    "username": "username",
    "firstname": "firstname",
    "lastname": "lastname",
    "email":{
        "email": "something@else.com",
        "verified": false
    },
    "status": "active",
    "banned": false
}

/ownSubscription (GET)

Recieve userId and performe a db query to find if the user has active subscriptions. Returns subscribed: true if user has active subcriptions and subscribed: false otherwise.

Data Example

?userId=f0ea4e43-545c-4f8f-8c2a-6fe5af1c48c5

/tools

/myTools (GET)

Requires userId. Performes a db query to find this user's tool. Returns data in the following form. Includes auth.checkAdmin.

{
    "tools": [
        "Google Ads"
    ]
}

Data Example

?userId=f0ea4e43-545c-4f8f-8c2a-6fe5af1c48c5

/configurations

/saveWizardStatus (POST)

Creates a configuration record based on request's input. Field status is hardcoded to 'incomplete'. Includes validation. Return the new configuration record.

Data Example

{
    "userId": "userId",
    "name": "temp-web-app",
    "submitted": {
        "0": "something",
        "1": "somethingelse"
    },
    "pageNo": 2
}

/continueWizard (GET)

Search the db for "status:incomplete" records that matches the query parameters. Query params are userId and name. Return the matched configuration records.

Data Example

?userId=f0ea4e43-545c-4f8f-8c2a-6fe5af1c48c5&name=temp-web-app

/subscriptions

Only includes one endpoint, the getAll (explained on top)

/wizards

/getWizard (GET)

Search the db for one record that matches the query parameters. Query params are lang and name. Return the matched wizard record.

Data Example

?lang=el&name=ERISED_MAIN_FLOW

/getWizards (GET)

Search the db for records that matches the query parameter. Query param is lang. Return the matched wizard records.

Data Example

?lang=el

/createWizard (POST)

Creates a wizard record based on request's input. Includes validation. Return the new wizard record.

Data Example

{
    "lang": "el",
    "name": "TEMP_NAME_FLOW",
    "questions": [
        {
            "title": "temp",
            "type": "CHECKBOX_WITH_TEXT",
            "answers": [
                "Απάντηση1",
                "Απάντηση2"
            ],
            "pageNo": 0,
            "skippable": false
            },
            {
            "title": "temp2",
            "type": "CHECKBOX",
            "answers": [
                "Απάντηση5",
                "Απάντηση6",
                "Απάντηση7"
            ],
            "pageNo": 1,
            "skippable": false
            }
    ],
    "styles": [
        "tempStyle1",
        "tempStyle2"
    ]
}

/editWizard (POST)

Updates a wizard record that matches the given lang and name. Updatable fields are questions and styles. Includes validation. Return the new wizard record.

Data Example

{
    "lang": "de",
    "name": "ERISED_MAIN_FLOW",
    "questions": [
        {
            "title": "temdddp",
            "type": "CHECKBOX_WITH_TEXT",
            "answers": [
                "Απάντηση1",
                "Απάντηση2"
            ],
            "pageNo": 0,
            "skippable": false
            },
            {
            "title": "temp2",
            "type": "CHECKBOX",
            "answers": [
                "Απάντηση5",
                "Απάντηση6",
                "Απάντηση7"
            ],
            "pageNo": 1,
            "skippable": false
            }
    ],
    "styles": [
        "tempStyle1",
        "tempStyle2"
    ]
}

/microservices

/syncMicroservices (GET)

Used for server db cloning sync (mqtt). Hardcoded messages are broadcasted to all microservices/# subscribers. Return 'SUCCESS' or 'FAILED' depended on errors during publishing.

/translations

/findMissing (GET)

Used for the translation tool. Takes no parameters. Configuration is needed in the config file.

Returned Data Example

{
    "client": "erised-web-app",
    "missing": [
        {
            "lang": "de",
            "keys": [
                "HOME",
                "ABOUT"
            ]
        },
        {
            "lang": "el",
            "keys": [
                "ABOUT",
                "CONTACT"
            ]
        },
        {
            "lang": "it",
            "keys": [
                "HOME",
                "ABOUT",
                "CONTACT"
            ]
        }
    ]
}

/media/users

/upload (POST)

Require the express-fileupload middleware. Link: https://www.npmjs.com/package/express-fileupload

Receives an png image and uploads it to Minio.