### Start Individual Microservice Source: https://context7.com/lomray-software/microservices/llms.txt Navigate to a specific microservice directory, install dependencies, and start the development server. Repeat for other required microservices. ```bash cd microservices/configuration && npm ci && npm run start:dev cd microservices/authentication && npm ci && npm run start:dev ``` -------------------------------- ### Start All Microservices and Infrastructure Source: https://context7.com/lomray-software/microservices/llms.txt Use this command to start the Inverted JSON job server, PostgreSQL, and all microservices simultaneously. Alternatively, start infrastructure first and then individual services. ```bash docker-compose -f docker-compose.yml -f docker-compose.ms.yml up ``` ```bash docker-compose up # starts ijson (port 8001) and postgres (port 5432) ``` -------------------------------- ### Run Configuration Microservice with Node Source: https://github.com/lomray-software/microservices/blob/staging/README.md Starts the configuration microservice directly using Node.js. This requires navigating to the service's directory, installing dependencies, and running the development start script. ```bash cd microservices/configuration npm i npm run start:dev ``` -------------------------------- ### Start Microservice Development Source: https://github.com/lomray-software/microservices/blob/staging/microservices/files/README.md Command to start the microservice in development mode. Ensure environment variables are configured. ```bash npm run start:dev ``` -------------------------------- ### Install Microservice Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/files/README.md Command to install the microservice as an npm package for use in other projects. ```bash npm i --save @lomray/microservice-files ``` -------------------------------- ### Install Microservice Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/content/README.md Installs the microservice as an npm package for use in other projects. ```bash npm i --save @lomray/microservice-content ``` -------------------------------- ### Setup Stripe Connect Account using cURL Source: https://context7.com/lomray-software/microservices/llms.txt Initiates the setup process for a Stripe Connect account, enabling users to receive funds. This method returns an onboarding link for the user to complete the setup. Specify `accountType` as 'standard' or 'instant'. ```bash # Setup connected account (returns onboarding link) curl http://localhost:8001/ms/payment-stripe \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "stripe.connect-account", "params": { "userId": "admif8f1-17f8-4501-9de2-a6e775ea39f3", "email": "receiver@example.com", "accountType": "standard", "refreshUrl": "https://myapp.com/onboarding/refresh", "returnUrl": "https://myapp.com/onboarding/complete" } }' ``` -------------------------------- ### Install Microservice Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/gateway/README.md Command to install the microservice as an npm package. Use this for integrating the gateway into other projects. ```bash npm i --save @lomray/microservice-gateway ``` -------------------------------- ### Install Blog Microservice as NPM Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/blog/README.md Install the blog microservice as a dependency in your project using npm. ```bash npm i --save @lomray/microservice-blog ``` -------------------------------- ### Initialize Stripe and Setup Payment Element Source: https://github.com/lomray-software/microservices/blob/staging/microservices/payment-stripe/src/templates/card/setup-intent.html Initializes Stripe with your public key, creates a Payment Element with a client secret, and mounts it to the DOM. This is the first step in collecting card details for a Setup Intent. ```javascript const stripe = Stripe('Stripe public key'); const options = { clientSecret: "Client secret from setup intent", // Fully customizable with appearance API. appearance: {/*...*/}, }; // Set up Stripe.js and Elements to use in the checkout form, passing the client secret obtained in step 3 const elements = stripe.elements(options); // Create and mount the Payment Element const paymentElement = elements.create('payment'); paymentElement.mount('#payment-element'); ``` -------------------------------- ### Install Microservice as NPM Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/payment-stripe/README.md Command to install the payment-stripe microservice as a dependency in your project. ```bash npm i --save @lomray/microservice-payment-stripe ``` -------------------------------- ### Install NPM Dependencies Source: https://github.com/lomray-software/microservices/blob/staging/microservices/files/README.md Command to install npm dependencies. Run this in both the root and local project folders. ```bash npm ci ``` -------------------------------- ### Install Authentication Microservice as NPM Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/authentication/README.md Installs the authentication microservice as a dependency in your project using npm. ```bash npm i --save @lomray/microservice-authentication ``` -------------------------------- ### Install Microservice Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/configuration/README.md Installs the configuration microservice as an npm package. Use this command to add it to your project dependencies. ```bash npm i --save @lomray/microservice-configuration ``` -------------------------------- ### Install Microservice as NPM Package Source: https://github.com/lomray-software/microservices/blob/staging/template/new/README.md Installs the microservice as a dependency for another project. Use `--save` to add it to package.json. ```bash npm i --save @lomray/microservice-microservice-name ``` -------------------------------- ### Create and List Blog Articles Source: https://context7.com/lomray-software/microservices/llms.txt These commands demonstrate how to create a new blog article and list published articles. Ensure the blog microservice is installed and an authorization token is provided for creation. ```bash npm i --save @lomray/microservice-blog ``` ```bash # Create a blog article (via gateway) curl -X POST http://127.0.0.1:3000 \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer admintokenooooooooooooooooooooon' \ -d '{ "id": "1", "method": "blog.article.create", "params": { "fields": { "title": "My First Article", "content": "Hello world content here.", "alias": "my-first-article", "status": "published" } } }' ``` ```bash # List published articles curl -X POST http://127.0.0.1:3000 \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "blog.article.list", "params": { "query": { "where": { "status": "published" }, "orderBy": { "createdAt": "DESC" } } } }' ``` -------------------------------- ### Install Users Microservice as npm Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/users/README.md Installs the Users microservice as a dependency in your project using npm. ```bash npm i --save @lomray/microservice-users ``` -------------------------------- ### Make Request to Blog Microservice Source: https://github.com/lomray-software/microservices/blob/staging/microservices/blog/README.md Example of how to make a request to the blog microservice using curl. This demonstrates the expected request format. ```bash curl localhost:8001/ms/blog -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Install Authorization Microservice as npm Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/authorization/README.md Command to install the authorization microservice as a dependency in your project. ```bash npm i --save @lomray/microservice-authorization ``` -------------------------------- ### Setup Stripe Connect Account Source: https://context7.com/lomray-software/microservices/llms.txt Sets up a Stripe Connect account for users who need to receive funds, returning an onboarding link. ```APIDOC ## POST /ms/payment-stripe ### Description Sets up a Stripe Connect account and returns an onboarding link. ### Method POST ### Endpoint http://localhost:8001/ms/payment-stripe ### Request Body - **id** (string) - Required - Unique identifier for the request. - **method** (string) - Required - The method to call, should be "stripe.connect-account". - **params** (object) - Required - Parameters for the method. - **userId** (string) - Required - The ID of the application user. - **email** (string) - Required - The email address of the user. - **accountType** (string) - Required - The type of account ('standard' or 'express'). - **refreshUrl** (string) - Required - The URL to redirect to if the onboarding needs to be refreshed. - **returnUrl** (string) - Required - The URL to redirect to upon completion of the onboarding. ### Request Example ```json { "id": "1", "method": "stripe.connect-account", "params": { "userId": "admif8f1-17f8-4501-9de2-a6e775ea39f3", "email": "receiver@example.com", "accountType": "standard", "refreshUrl": "https://myapp.com/onboarding/refresh", "returnUrl": "https://myapp.com/onboarding/complete" } } ``` ### Response #### Success Response (200) - **result** (object) - The result of the operation. - **url** (string) - The URL for the Stripe onboarding process. #### Response Example ```json { "result": { "url": "https://connect.stripe.com/setup/..." } } ``` ``` -------------------------------- ### Install Cron Microservice as NPM Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/cron/README.md Install the microservice as a dependency in your project using npm. ```bash npm i --save @lomray/microservice-cron ``` -------------------------------- ### Install Microservice NPM Package Source: https://github.com/lomray-software/microservices/blob/staging/README.md Installs a specific microservice as an npm package. Replace 'NAME' with the desired microservice, e.g., 'configuration'. ```bash npm i --save @lomray/microservice-NAME # for e.g. npm i --save @lomray/microservice-configuration ``` -------------------------------- ### Run Configuration Microservice with Docker Source: https://github.com/lomray-software/microservices/blob/staging/README.md Starts the configuration microservice using Docker Compose. This is useful for isolated testing or development of this specific service. ```bash docker-compose -f docker-compose.ms.yml up configuration ``` -------------------------------- ### Demo Request to Configuration Microservice Source: https://github.com/lomray-software/microservices/blob/staging/microservices/configuration/README.md Example of making a demo request to the configuration microservice using curl. The request includes a unique ID, method, and parameters. ```bash curl localhost:8001/ms/configuration -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Start PostgreSQL and Inverted Json Server Source: https://github.com/lomray-software/microservices/blob/staging/README.md Initiates the PostgreSQL database and the Inverted Json job server. This is a prerequisite for running other microservices. ```bash docker-compose up ``` -------------------------------- ### Demo Request to Microservice Source: https://github.com/lomray-software/microservices/blob/staging/microservices/files/README.md Example cURL command to send a demo request to the microservice. Replace 'unique-id' with a specific identifier. ```bash curl localhost:8001/ms/files -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Install Notification Microservice as npm Package Source: https://github.com/lomray-software/microservices/blob/staging/microservices/notification/README.md Install the notification microservice as a dependency in your project using npm. ```bash npm i --save @lomray/microservice-notification ``` -------------------------------- ### Make a Demo Request Source: https://github.com/lomray-software/microservices/blob/staging/microservices/payment-stripe/README.md Example cURL command to make a demo request to the payment-stripe microservice. Adjust the port and payload as needed. ```bash curl localhost:8001/ms/payment-stripe -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Handle Form Submission for Setup Intent Confirmation Source: https://github.com/lomray-software/microservices/blob/staging/microservices/payment-stripe/src/templates/card/setup-intent.html Attaches an event listener to the payment form to prevent default submission, then confirms the Setup Intent using the provided elements and client secret. Displays any errors or a success message. ```javascript const form = document.getElementById('payment-form'); form.addEventListener('submit', async (event) => { event.preventDefault(); const {error} = await stripe.confirmSetup({ elements, confirmParams: { return_url: 'https://example.com/account/payments/setup-complete', } }); const messageContainer = document.querySelector('#error-message'); messageContainer.textContent = error ? error.message : "Payment setup successful"; }); ``` -------------------------------- ### Make Request to Users Microservice Source: https://github.com/lomray-software/microservices/blob/staging/microservices/users/README.md Example of how to send a request to the Users microservice using curl. The request includes an ID, method, and parameters. ```bash curl localhost:8001/ms/users -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Make a Microservice Request Source: https://github.com/lomray-software/microservices/blob/staging/microservices/content/README.md Example cURL command to make a request to the microservice. Replace 'unique-id' with a specific identifier. ```bash curl localhost:8001/ms/content -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Make Request to Microservice Source: https://github.com/lomray-software/microservices/blob/staging/template/new/README.md Example of making a request to the microservice using curl. Replace 'unique-id' with a valid identifier and 'demo' with the desired method. ```bash curl localhost:8001/ms/microservice-name -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Run All Microservices with Docker Compose Source: https://github.com/lomray-software/microservices/blob/staging/README.md Use this command to run all microservices simultaneously using Docker Compose. Ensure you have Docker installed and configured. ```bash docker-compose -f docker-compose.yml -f docker-compose.ms.yml up ``` -------------------------------- ### Stripe CLI: Listen for Connect Events Source: https://github.com/lomray-software/microservices/blob/staging/microservices/payment-stripe/README.md Command to start the Stripe CLI to listen for connect-related events and forward them to a local webhook endpoint. ```bash stripe listen --forward-connect-to 'http://localhost:3000/webhook/payment-stripe.stripe.webhook/webhooktokenoooooooooooooooooooo?id=connect' ``` -------------------------------- ### Send Demo Request to Notification Microservice Source: https://github.com/lomray-software/microservices/blob/staging/microservices/notification/README.md Example cURL command to send a demo request to the notification microservice. Adjust the port if necessary. ```bash curl localhost:8001/ms/notification -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Extend Microservice Command Source: https://github.com/lomray-software/microservices/blob/staging/template/README.md Use this command to extend an existing microservice, for example, the 'users' microservice in a staging environment. ```shell microservices extend users --staging ``` -------------------------------- ### Stripe CLI: Listen for Account Events Source: https://github.com/lomray-software/microservices/blob/staging/microservices/payment-stripe/README.md Command to start the Stripe CLI to listen for account-related events and forward them to a local webhook endpoint. ```bash stripe listen --forward-to 'http://localhost:3000/webhook/payment-stripe.stripe.webhook/webhooktokenoooooooooooooooooooo?id=account' ``` -------------------------------- ### Make a Request to Authorization Microservice Source: https://github.com/lomray-software/microservices/blob/staging/microservices/authorization/README.md Example cURL command to send a request to the authorization microservice. This demonstrates the expected request format. ```bash curl localhost:8001/ms/authorization -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Send POST Request to Microservice Source: https://github.com/lomray-software/microservices/blob/staging/README.md Example of sending a POST request to a microservice endpoint. This demonstrates the expected request format for interacting with the services. ```bash curl -X POST http://127.0.0.1:3000 \ -H 'Content-Type: application/json' \ -d '{"id":"unique-id-1","method":"microservice-name.method","params":{}}' ``` -------------------------------- ### Define and Use CMS Components Source: https://context7.com/lomray-software/microservices/llms.txt This sequence defines a reusable component with a schema and then creates a single-type page using that component. Ensure the content microservice is installed. ```bash npm i --save @lomray/microservice-content ``` ```bash # Step 1: Define a reusable component with a schema curl http://localhost:8001/ms/content \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "component.create", "params": { "fields": { "alias": "pageHeader", "title": "Page Header", "schema": [ { "name": "headerTitle", "title": "Header title", "type": "text" }, { "name": "postNumber", "title": "Post number", "type": "number" } ] } } }' ``` ```bash # Step 2: Create a single-type page using the component curl http://localhost:8001/ms/content \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "single-type.create", "params": { "fields": { "components": [{ "id": "9a7aedb4-4b00-44b3-89a3-a535692d28d6" }], "title": "Home Page", "alias": "homePage", "value": { "pageHeader": { "id": "9a7aedb4-4b00-44b3-89a3-a535692d28d6", "data": { "headerTitle": "Welcome", "postNumber": 1 } } } } } }' ``` ```bash # Step 3: View single-type and expand cross-microservice relations curl http://localhost:8001/ms/content \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "single-type.view", "params": { "query": { "where": { "id": "c59cdc52-86d0-4d61-bc8e-ab770fc1fd7b" } }, "payload": { "expand": [ { "route": "blogPostPage.content.pageContent.contentCreators", "relations": ["profile"] } ] } } }' ``` -------------------------------- ### Run Integration Tests for Microservices Source: https://context7.com/lomray-software/microservices/llms.txt Executes the integration test suite after ensuring all microservices are running. Requires navigating to the 'tests' directory and installing dependencies. ```bash cd tests npm ci npm run test ``` -------------------------------- ### Create Stripe Customer Source: https://context7.com/lomray-software/microservices/llms.txt Creates a Stripe customer record linked to an application user, initiating the payment setup flow. ```APIDOC ## POST /ms/payment-stripe ### Description Creates a Stripe customer record linked to an application user. ### Method POST ### Endpoint http://localhost:8001/ms/payment-stripe ### Request Body - **id** (string) - Required - Unique identifier for the request. - **method** (string) - Required - The method to call, should be "customer.create". - **params** (object) - Required - Parameters for the method. - **userId** (string) - Required - The ID of the application user. - **name** (string) - Required - The name of the customer. - **email** (string) - Required - The email address of the customer. ### Request Example ```json { "id": "1", "method": "customer.create", "params": { "userId": "userf8f1-17f8-4501-9de2-a6e775ea39f3", "name": "John Doe", "email": "john@doe.com" } } ``` ### Response #### Success Response (200) - **result** (object) - The result of the operation. - **id** (string) - The internal ID of the customer record. - **stripeCustomerId** (string) - The ID of the customer in Stripe. - **userId** (string) - The ID of the application user. #### Response Example ```json { "result": { "id": "...", "stripeCustomerId": "cus_...", "userId": "..." } } ``` ``` -------------------------------- ### Make Authentication Request Source: https://github.com/lomray-software/microservices/blob/staging/microservices/authentication/README.md Example of making a request to the authentication microservice using curl. The request body includes an ID, method, and parameters. ```bash curl localhost:8001/ms/authentication -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Make Request to Cron Microservice Source: https://github.com/lomray-software/microservices/blob/staging/microservices/cron/README.md Example cURL command to send a request to the cron microservice. Replace 'unique-id' with a unique identifier. ```bash curl localhost:8001/ms/cron -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Make Gateway Request Source: https://github.com/lomray-software/microservices/blob/staging/microservices/gateway/README.md Example cURL commands to make requests to the gateway. One targets the default gateway port, the other a specific port. ```bash curl localhost:8001/ms/gateway -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` ```bash curl localhost:3000 -d '{"id": "unique-id", "method": "demo", "params": {}}' ``` -------------------------------- ### Create Stripe Payment Intent with Fees using cURL Source: https://context7.com/lomray-software/microservices/llms.txt Generates a Stripe PaymentIntent, automatically calculating fees and taxes. This example demonstrates sender-paid fees and additional revenue splits. Configure `MS_FEES` and `MS_TAX` environment variables for accurate calculations. ```bash # Example: sender pays fees, 3% application fee, 1% extra to receiver curl http://localhost:8001/ms/payment-stripe \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "stripe.create-payment-intent", "params": { "userId": "userf8f1-17f8-4501-9de2-a6e775ea39f3", "receiverId": "admif8f1-17f8-4501-9de2-a6e775ea39f3", "entityId": "entity08-ecd6-483a-9117-2af2e104b5f8", "entityCost": 100, "feesPayer": "sender", "title": "Concert ticket", "applicationPaymentPercent": 3, "extraReceiverRevenuePercent": 1 } }' ``` -------------------------------- ### Create Batch Notifications Source: https://context7.com/lomray-software/microservices/llms.txt This command creates multiple in-app notifications for different users. It requires the notification microservice to be installed and configured with email providers if needed. ```bash npm i --save @lomray/microservice-notification # EMAIL_PROVIDER=nodemailer # EMAIL_DEFAULT_FROM=no-reply@example.com # EMAIL_TRANSPORTER_OPTIONS='{"host":"smtp.example.com","port":587,"auth":{"user":"u","pass":"p"}}' ``` ```bash curl http://localhost:8001/ms/notification \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "notice.create", "params": { "fields": [ { "userId": "6e6ed89f-637f-4fd6-86c2-95ef706cacf3", "title": "New task assigned", "description": "You have a new task waiting.", "type": "announce", "params": { "status": "warning", "isTemplate": true } }, { "userId": "5b86356f-bea2-469b-8a82-7566f369a1e0", "title": "Reminder", "description": "Your subscription expires soon.", "type": "announce", "params": { "status": "info", "isTemplate": false } } ] } }' # Response: { "result": [{ "id": "...", "userId": "...", "title": "..." }, ...] } ``` -------------------------------- ### Create Database Migration with Custom Fields Source: https://github.com/lomray-software/microservices/blob/staging/template/README.md Define a database migration to add custom fields to existing tables. This example shows how to add 'customField' to both 'profile' and 'user' tables using ALTER TABLE statements. ```typescript import { MigrationInterface, QueryRunner } from 'typeorm'; export default class init1650447115917 implements MigrationInterface { name = 'init1650447115917'; public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "profile" ADD "customField" character varying(255)`); await queryRunner.query(`ALTER TABLE "user" ADD "customField" character varying(255)`); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "profile" DROP COLUMN "customField"`); await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "customField"`); } } ``` -------------------------------- ### Get Stripe Account Balance Source: https://context7.com/lomray-software/microservices/llms.txt Retrieves the balance of a connected Stripe account. ```APIDOC ## POST /ms/payment-stripe ### Description Gets the balance of a connected Stripe account. ### Method POST ### Endpoint http://localhost:8001/ms/payment-stripe ### Request Body - **id** (string) - Required - Unique identifier for the request. - **method** (string) - Required - The method to call, should be "stripe.balance". - **params** (object) - Required - Parameters for the method. - **userId** (string) - Required - The ID of the application user associated with the Stripe account. ### Request Example ```json { "id": "1", "method": "stripe.balance", "params": { "userId": "admif8f1-17f8-4501-9de2-a6e775ea39f3" } } ``` ### Response #### Success Response (200) - **result** (object) - The result of the operation. The structure of this object depends on the Stripe API response for balance information. #### Response Example ```json { "result": { ... } } ``` ``` -------------------------------- ### Create New Microservice Source: https://github.com/lomray-software/microservices/blob/staging/template/README.md Use this command to create a new microservice from the template. Specify the desired name for your microservice. ```shell microservices create your-ms-name ``` -------------------------------- ### Blog Microservice - blog.article.create Source: https://context7.com/lomray-software/microservices/llms.txt Creates a new blog article. ```APIDOC ## blog.article.create ### Description Creates a new blog article. ### Method POST ### Endpoint /ms/blog ### Parameters #### Request Body - **id** (string) - Required - Unique identifier for the request. - **method** (string) - Required - The method to call, should be `blog.article.create`. - **params** (object) - Required - Parameters for the `blog.article.create` method. - **fields** (object) - Required - Fields for the article. - **title** (string) - Required - The title of the article. - **content** (string) - Required - The main content of the article. - **alias** (string) - Required - A unique alias for the article. - **status** (string) - Optional - The status of the article (e.g., `published`). ### Request Example ```json { "id": "1", "method": "blog.article.create", "params": { "fields": { "title": "My First Article", "content": "Hello world content here.", "alias": "my-first-article", "status": "published" } } } ``` ``` -------------------------------- ### User Sign-Up Flow Source: https://context7.com/lomray-software/microservices/llms.txt Complete user registration flow: send verification code via email, then sign up with the code. Requires `@lomray/microservice-users`. ```bash npm i --save @lomray/microservice-users # MS_USER_PASSWORD_SALT_ROUNDS=10 # MS_USER_REMOVE_ACCOUNT_RESTORE_TIME=0 (hours before permanent deletion) # Step 1: Send email verification code curl -X POST http://127.0.0.1:3000 \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "users.confirm-code.send", "params": { "type": "email", "login": "test@test.com" } }' # Step 2: Sign up with confirmation code curl -X POST http://127.0.0.1:3000 \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "users.user.sign-up", "params": { "fields": { "firstName": "Mike", "email": "test@test.com", "password": "123456789" }, "confirmBy": "email", "confirmCode": 729503 } }' # Response sets jwt-access and jwt-refresh cookies # Step 3: View the authenticated user (pass cookies) curl -X POST http://127.0.0.1:3000 \ -H 'Content-Type: application/json' \ -H 'Cookie: jwt-access=eyJ...' \ -d '{ "id": "1", "method": "users.user.view", "params": { "query": { "relations": ["profile"] } } }' # Response: { "result": { "id": "...", "email": "test@test.com", "profile": {...} } } ``` -------------------------------- ### Gateway Microservice - General Usage Source: https://context7.com/lomray-software/microservices/llms.txt The gateway acts as the single HTTP entry point for all clients, accepting JSON-RPC 2.0 requests and routing them to the appropriate microservice. Method names follow the pattern `..`. ```APIDOC ## Gateway Microservice - General Usage ### Description The gateway is the single HTTP entry point for all clients. It accepts JSON-RPC 2.0 requests and routes them to the appropriate downstream microservice. Method names follow the pattern `..` (e.g., `users.user.sign-up`). ### Method POST ### Endpoint `http://host:3000` ### Request Example ```json { "id": "1", "method": "users.user.view", "params": {} } ``` ### Response Example (Varies based on the called microservice method) ``` -------------------------------- ### Users Microservice - User Sign-Up Flow Source: https://context7.com/lomray-software/microservices/llms.txt Handles the complete user registration process, including sending verification codes via email and creating a user account with confirmation. ```APIDOC ## User Sign-Up Flow ### Description Full registration flow: send verification code → create user with confirmation. ### Step 1: Send email verification code #### Method POST #### Endpoint http://127.0.0.1:3000 #### Request Body - **id** (string) - Required - Identifier for the request. - **method** (string) - Required - The method to call, should be "users.confirm-code.send". - **params** (object) - Required - Parameters for the method. - **type** (string) - Required - The type of confirmation, e.g., "email". - **login** (string) - Required - The user's login identifier (e.g., email address). ### Step 2: Sign up with confirmation code #### Method POST #### Endpoint http://127.0.0.1:3000 #### Request Body - **id** (string) - Required - Identifier for the request. - **method** (string) - Required - The method to call, should be "users.user.sign-up". - **params** (object) - Required - Parameters for the method. - **fields** (object) - Required - User fields. - **firstName** (string) - Required - User's first name. - **email** (string) - Required - User's email address. - **password** (string) - Required - User's password. - **confirmBy** (string) - Required - The method used for confirmation, e.g., "email". - **confirmCode** (number) - Required - The confirmation code received. ### Step 3: View the authenticated user (pass cookies) #### Method POST #### Endpoint http://127.0.0.1:3000 #### Headers - **Cookie** (string) - Required - JWT access token cookie. #### Request Body - **id** (string) - Required - Identifier for the request. - **method** (string) - Required - The method to call, should be "users.user.view". - **params** (object) - Required - Parameters for the method. - **query** (object) - Optional - Query parameters for fetching user data. - **relations** (array) - Optional - Relations to include, e.g., ["profile"]. ### Response #### Success Response (200) - **result** (object) - Contains the user data. - **id** (string) - User's unique identifier. - **email** (string) - User's email address. - **profile** (object) - User's profile information. ``` -------------------------------- ### Sync Permissions with Database Source: https://github.com/lomray-software/microservices/blob/staging/microservices/authorization/README.md Command to synchronize the default permissions defined in `permissions/list` with the microservice's database. ```bash npm run sync:permissions ``` -------------------------------- ### Initiate Instant Payout with Stripe Source: https://context7.com/lomray-software/microservices/llms.txt Initiates an instant payout to an external account using the payment-stripe microservice. Requires user ID and amount. ```bash curl http://localhost:8001/ms/payment-stripe \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "stripe.instant-payout", "params": { "userId": "admif8f1-17f8-4501-9de2-a6e775ea39f3", "amount": 5000 } }' ``` -------------------------------- ### Run Integration Tests Source: https://github.com/lomray-software/microservices/blob/staging/README.md Executes integration tests for the microservices. This involves running all microservices first, then executing the test suite from the 'tests' directory. ```bash cd tests npm run test ``` -------------------------------- ### Get Stripe Connected Account Balance using cURL Source: https://context7.com/lomray-software/microservices/llms.txt Retrieves the current balance of a Stripe Connect account. This is useful for displaying available funds to users who receive payments. Ensure the `userId` corresponds to a user with a connected Stripe account. ```bash curl http://localhost:8001/ms/payment-stripe \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "stripe.balance", "params": { "userId": "admif8f1-17f8-4501-9de2-a6e775ea39f3" } }' ``` -------------------------------- ### Blog Microservice - blog.article.list Source: https://context7.com/lomray-software/microservices/llms.txt Lists published blog articles, with options for ordering. ```APIDOC ## blog.article.list ### Description Lists published blog articles, with options for ordering. ### Method POST ### Endpoint /ms/blog ### Parameters #### Request Body - **id** (string) - Required - Unique identifier for the request. - **method** (string) - Required - The method to call, should be `blog.article.list`. - **params** (object) - Required - Parameters for the `blog.article.list` method. - **query** (object) - Optional - Query parameters for filtering and ordering. - **where** (object) - Optional - Conditions for filtering (e.g., by `status`). - **orderBy** (object) - Optional - Specifies the order of results (e.g., `createdAt: "DESC"`). ### Request Example ```json { "id": "1", "method": "blog.article.list", "params": { "query": { "where": { "status": "published" }, "orderBy": { "createdAt": "DESC" } } } } ``` ``` -------------------------------- ### Create Stripe Customer using cURL Source: https://context7.com/lomray-software/microservices/llms.txt Sets up a Stripe customer record associated with an application user. This is a prerequisite for payment processing. Ensure the Stripe API key and configuration are correctly set. ```bash curl http://localhost:8001/ms/payment-stripe \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "customer.create", "params": { "userId": "userf8f1-17f8-4501-9de2-a6e775ea39f3", "name": "John Doe", "email": "john@doe.com" } }' ``` -------------------------------- ### Content Microservice - single-type.create Source: https://context7.com/lomray-software/microservices/llms.txt Creates a single-type page using defined components and conforming to their schemas. ```APIDOC ## single-type.create ### Description Creates a single-type page using defined components and conforming to their schemas. ### Method POST ### Endpoint /ms/content ### Parameters #### Request Body - **id** (string) - Required - Unique identifier for the request. - **method** (string) - Required - The method to call, should be `single-type.create`. - **params** (object) - Required - Parameters for the `single-type.create` method. - **fields** (object) - Required - Fields for the single-type page. - **components** (array) - Required - An array of component IDs used in this page. - **title** (string) - Required - The title of the single-type page. - **alias** (string) - Required - A unique alias for the single-type page. - **value** (object) - Required - The data for the single-type page, structured by component. ### Request Example ```json { "id": "1", "method": "single-type.create", "params": { "fields": { "components": [{ "id": "9a7aedb4-4b00-44b3-89a3-a535692d28d6" }], "title": "Home Page", "alias": "homePage", "value": { "pageHeader": { "id": "9a7aedb4-4b00-44b3-89a3-a535692d28d6", "data": { "headerTitle": "Welcome", "postNumber": 1 } } } } } } ``` ``` -------------------------------- ### Forward Stripe Webhooks for Local Development Source: https://context7.com/lomray-software/microservices/llms.txt Forwards Stripe webhooks to a local development server using the Stripe CLI. Use separate commands for general webhooks and connect webhooks. ```bash stripe listen --forward-to 'http://localhost:3000/webhook/payment-stripe.stripe.webhook/webhooktokenoooooooooooooooooooo?id=account' ``` ```bash stripe listen --forward-connect-to 'http://localhost:3000/webhook/payment-stripe.stripe.webhook/webhooktokenoooooooooooooooooooo?id=connect' ``` -------------------------------- ### Retrieve Configuration Value Source: https://context7.com/lomray-software/microservices/llms.txt Use this command to retrieve a specific configuration value from the configuration microservice. Ensure the configuration microservice is running. ```bash docker-compose -f docker-compose.ms.yml up configuration ``` ```bash curl http://localhost:8001/ms/configuration \ -H 'Content-Type: application/json' \ -d '{ "id": "1", "method": "config.view", "params": { "query": { "where": { "key": "email.from" } }, "payload": { "isInternal": true } } }' ``` -------------------------------- ### Check Code Coverage Source: https://github.com/lomray-software/microservices/blob/staging/microservices/files/README.md Command to check the code coverage of the microservice tests using NYC. ```bash nyc npm run test ``` -------------------------------- ### Run Inverted Json Job Server Source: https://github.com/lomray-software/microservices/blob/staging/microservices/files/README.md Command to run the Inverted Json job server, which is a dependency for the microservice. ```bash docker run -it -p 8001:8001 lega911/ijson --log 47 ``` -------------------------------- ### Notification Microservice - notice.create Source: https://context7.com/lomray-software/microservices/llms.txt Creates in-app notifications for one or more users. Supports batch creation. Notice types include `announce`, `task`, etc. The `params` field supports custom metadata like status indicators and template flags. ```APIDOC ## notice.create ### Description Creates in-app notifications for one or more users. Supports batch creation. Notice types include `announce`, `task`, etc. The `params` field supports custom metadata like status indicators and template flags. ### Method POST ### Endpoint /ms/notification ### Parameters #### Request Body - **id** (string) - Required - Unique identifier for the request. - **method** (string) - Required - The method to call, should be `notice.create`. - **params** (object) - Required - Parameters for the `notice.create` method. - **fields** (array) - Required - An array of notification objects to create. - **userId** (string) - Required - The ID of the user to send the notification to. - **title** (string) - Required - The title of the notification. - **description** (string) - Required - The description of the notification. - **type** (string) - Required - The type of notice (e.g., `announce`, `task`). - **params** (object) - Optional - Custom metadata for the notification. ### Request Example ```json { "id": "1", "method": "notice.create", "params": { "fields": [ { "userId": "6e6ed89f-637f-4fd6-86c2-95ef706cacf3", "title": "New task assigned", "description": "You have a new task waiting.", "type": "announce", "params": { "status": "warning", "isTemplate": true } }, { "userId": "5b86356f-bea2-469b-8a82-7566f369a1e0", "title": "Reminder", "description": "Your subscription expires soon.", "type": "announce", "params": { "status": "info", "isTemplate": false } } ] } } ``` ### Response #### Success Response (200) - **result** (array) - An array of created notification objects, each containing at least `id`, `userId`, and `title`. ``` -------------------------------- ### Verify Gateway Status Source: https://context7.com/lomray-software/microservices/llms.txt Send a POST request to the gateway to verify it is running and responsive. This is a basic check to ensure the gateway is accessible. ```bash curl -X POST http://127.0.0.1:3000 \ -H 'Content-Type: application/json' \ -d '{"id":"req-1","method":"demo","params":{}}' ```