![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
A node library to implement an OSB broker which can register multiple OSB services
api/OSB.js
: broker class which allow clients to register OSB services.
app
- REQUIRED: express apposbPath
- REQUIRED: base path for OSB endpointscontextBuilder
- OPTIONAL: function to build context for each requestsapi/OSBService
: represent an OSB service which handle OSB requests. Each OSBService
needs to implement below functions to handle OSB requests for the service.
getServiceInfo
: return service infoprovisionServiceInstance
: async function to provision service instanceupdateServiceInstance
: async function to update service instancedeprovisionServiceInstance
: async function to deprovision service instancebindService
: async function to bind serviceunbindService
: async function to unbind servicepollLastOperation
: async function to get last operation status{
statusCode: 'the-http-status-code',
data: 'the response'
}
api/model/*
: model classes represent OSB responsesapi/model/request/*
: model classes represent OSB request paramsconst express = require('express');
const osbNode = require('osb-node');
const OSB = osbNode.OSB;
const OSBService = osbNode.OSBService;
const app = express();
const broker = new OSB(app, {osbPath: osbPath, contextBuilder: function(httpRequest){
return {key: 'value};
});
broker.registerService(new OSBService({
getServiceInfo,
provisionServiceInstance,
updateServiceInstance,
deprovisionServiceInstance,
bindService,
unbindService,
pollLastOperation
}));
broker.start();
const Plan = osbOnode.modelPlan;
const Schemas = osbOnode.modelSchemas;
const ServiceBindingSchema = osbOnode.modelServiceBindingSchema;
const Service = osbOnode.modelService;
const ServiceInstanceSchema = osbOnode.modelServiceInstanceSchema;
function getServiceInfo(request, context) {
return new Service({
name: 'service-a',
id: 'service-id',
description: 'service A',
tags: ['tag', 'osb'],
requires: ['route_forwarding'],
bindable: true,
metadata: {
displayName: 'Service 1',
provider: {
name: 'provider name'
}
},
dashboard_client: new DashboardClient({
id: '7545b455-9cdb-41d2-abf3-3a4bae383a43',
secret: '277cabb0-XXXX-XXXX-XXXX-7822c0a90e5d',
redirect_uri: 'http://localhost:1234'
}),
plan_updateable: true,
plans: [new Plan({
id: 'ab3eb1db-26d7-429a-850a-daeb667e0530',
name: 'plan-1',
description: 'description',
metadata: {
max_storage_tb: 5,
costs: [{
amount: {
usd: 99.0
},
unit: 'MONTHLY'
}, {
amount: {
usd: 0.99
},
unit: '1GB of messages over 20GB'
}],
bullets: [
'Shared fake server',
'5 TB storage',
'40 concurrent connections'
]
},
schemas: new Schemas({
service_instance: new ServiceInstanceSchema({
create: new InputParameters({
parameters: {
'$schema': 'http://json-schema.org/draft-04/schema#',
'type': 'object',
'billing-account': {
description: 'Billing account number used to charge use of shared fake server.',
type: 'string'
}
}
}),
update: new InputParameters({
parameters: {
'$schema': 'http://json-schema.org/draft-04/schema#',
'type': 'object',
'billing-account': {
description: 'Billing account number used to charge use of shared fake server.',
type: 'string'
}
}
})
}),
service_binding: new ServiceBindingSchema({
create: new InputParameters({
parameters: {
'$schema': 'http://json-schema.org/draft-04/schema#',
'type': 'object',
'billing-account': {
description: 'Billing account number used to charge use of shared fake server.',
type: 'string'
}
}
})
})
})
}, new Plan({
id: '11f48b05-e3f3-4265-bdf7-6a0c58dbc9bf',
name: 'plan-2',
description: 'Shared fake Server, 5tb persistent disk, 40 max concurrent connections. 100 async',
free: false,
metadata: {
max_storage_tb: 5,
costs: [{
amount: {
usd: 199.0
},
unit: 'MONTHLY'
}, {
amount: {
usd: 0.99
},
unit: '1GB of messages over 20GB'
}],
bullets: [
'40 concurrent connections'
]
}
}))]
});
}
const ProvisionResponse = osbNode.model.ProvisionResponse;
function provisionServiceInstance(request, context) {
return {
statusCode: '200',
data: new ProvisionResponse({dashboard_url: 'https://service-dashboard', operation: 'provision'});
}
}
const LastOperation = osbNode.model.LastOperation;
new LastOperation({state: 'in progress', description: 'provisioning instance'});
const BrokerError = osbNode.model.BrokerError;
new BrokerError({error: 'invalid request', description: 'service id is required'});
More details are in test-app.js
Please see CODE_OF_CONDUCT.md
Please see CONTRIBUTING.md
We license this project under the Apache License 2.0, as per our LICENSE.txt
FAQs
OSB nodejs module
The npm package osb-node receives a total of 4 weekly downloads. As such, osb-node popularity was classified as not popular.
We found that osb-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.