![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
kinvey-flex-sdk
Advanced tools
This is the SDK for code execution of Flex Microservices. The module provides a framework for building Kinvey-backed services using FlexData, FlexFunctions, and FlexAuth.
To install this project, add kinvey-flex-sdk
to your package.json
file and install it via npm
npm install kinvey-flex-sdk
Or install it with yarn
:
yarn add kinvey-flex-sdk
To use this module, require it in your project as such:
const sdk = require('kinvey-flex-sdk');
This section contains standalone sample microservices for FlexData, FlexFunctions, and FlexAuth frameworks. Note that all three can be combined into one service and are separated for example purposes.
When developing and testing FlexServices locally, you can specify a host and port to listen on by passing an options object with an optional host and port. If no host/port is specified, localhost:10001 will be used:
sdk.service({ host: 'somehost', port: 7777 }, (err, flex) => {
// code goes here
});
You can also specify a shared secret (i.e. a secret key) to be used by this service. Any client that accesses this service must contain this shared secret, or requests will be rejected with a 401 Unauthorized
error.
sdk.service({ sharedSecret: '<some shared secret>'} }, (err, flex) => {
// code goes here
});
Once set here, you must set this shared secret in the Kinvey console when configuring your service for Kinvey requests to execute properly. For testing locally, this shared secret can be passed in the X-Auth-Key
http header.
const sdk = require('kinvey-flex-sdk');
sdk.service(function(err, flex) {
const data = flex.data; // gets the FlexData object from the service
function getRecordById(request, complete, modules) {
let entityId = request.entityId;
let entity = null;
// Do some logic to get the entity id from the remote data store
// Assume that data is retrieved and stored in "entity" variable
// After entity is retrieved, check to see if it exists
if (typeof entity === 'undefined' || entity === null) {
return complete("The entity could not be found").notFound().next();
} else {
// return the entity
return complete().setBody(entity).ok().next();
}
}
// set the serviceObject
const widgets = data.serviceObject('widgets');
// wire up the event that we want to process
widgets.onGetById(getRecordById);
};
const sdk = require('kinvey-flex-sdk');
const request = require('request'); // assumes that the request module was added to package.json
sdk.service(function(err, flex) {
const flexFunctions = flex.functions; // gets the FlexFunctions object from the service
function getRedLineSchedule(context, complete, modules) {
request.get('http://developer.mbta.com/Data/Red.json', (err, response, body) => {
// if error, return an error
if (err) {
return complete().setBody("Could not complete request").runtimeError().done();
}
// otherwise, return the results
return complete().setBody(body).ok().done();
});
}
// set the handler
flexFunctions.register('getRedLineData', getRedLineSchedule);
};
const sdk = require('kinvey-flex-sdk');
const request = require('request'); // assumes that the request module was added to package.json
sdk.service(function(err, flex) {
const flexAuth = flex.auth; // gets the FlexAuth object from the service
function authenticate(context, complete, modules) {
// authenticate the user here
if (err) {
return complete().accessDenied(err).next();
}
return complete().setToken(token).ok().next();
}
// set the handler
flexFunctions.register('myAuth', authenticate);
};
Please contact Kinvey for further information or questions
2.0.5
FAQs
SDK for creating Kinvey Flex Services
The npm package kinvey-flex-sdk receives a total of 13 weekly downloads. As such, kinvey-flex-sdk popularity was classified as not popular.
We found that kinvey-flex-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.