1

Inside a custom endpoint in Kinvey, I see the modules parameter which exposes inbuilt modules like so:

function onRequest(request, response, modules) {
}

I could see from the documentation here that Kinvey has some existing inbuilt functions

http://devcenter.kinvey.com/rest/reference/business-logic/reference.html#modules

My questions are,

  1. Is it possible to have our own custom reusable modules defined somewhere in Kinvey and use it within the custom endpoint function above? If so how?

  2. Is it possible to define (similar to package.json) and use external npm packages within the above custom endpoint function?

Harindaka
  • 4,658
  • 8
  • 43
  • 62

2 Answers2

2

Great to see that you show interest in using Kinvey!

Regarding your questions - yes, if I got you correctly both are possible. See below for further explanations...

  1. You can implement Common Code, and use it to create reusable functions which can be used across your business logic scripts. Please refer to the following link for more information.
  2. You can implement Kinvey Flex Services, which are low code, lightweight NodeJS micro-services that are used for data integrations and functional business logic. FlexServices utilize the Flex SDK and can consist of FlexData for data integrations, FlexFunctions for trigger-based data pre/post hooks or custom endpoints, and FlexAuth for custom authentication through Mobile Identity Connect (MIC). Please refer to the following link for more information.

I hope, I have informed you well.

  • Can you call common code from the Flex Services Runtime? [`endpointRunner`](https://devcenter.kinvey.com/rest/reference/flex/reference.html#endpoint-runner-module) is not required, correct? – xinthose Dec 12 '18 at 19:03
  • @xinthose, you can call Business Logic Common Code easily without using the `endpointRunner` module. Please refer to this: https://devcenter.kinvey.com/nodejs/guides/business-logic#common-code. – Bilger Yahov Dec 13 '18 at 09:02
  • 1
    @xinthose, please keep in mind that Business Logic feature is different from Flex Services. Business Logic lets you create serverless code in a fast and easy way using the Web Console. Flex Services are NodeJS micro-services, which you develop on your machine, following which deploy to Flex Services Runtime. If you would like to re-use code with BL, you would need to use Common Code. That's not the case with Flex Services, since they are NodeJS micro-services on their own. https://github.com/bilger-progress/flex-graphql-article This is an example for a Flex Service. – Bilger Yahov Dec 13 '18 at 09:26
0

No, this is not possible in the free tier, in Business Logic you are limited to using the modules that are explicitly whitelisted.

There are options to run any node code (including any npm module you want) inside the platform in the paid "Business Edition".

Ivo Janssen
  • 476
  • 3
  • 9
  • Thank you for your answer. Please be kind enough to elaborate on how in the Business Edition allows you to run any node code including any npm module since I wasn't able to find such an option in the paid version of the Kinvey Dashboard. A link would also suffice. I'll look it up and add a more detailed comment here so that others will benefit too. – Harindaka Jun 10 '16 at 09:46