@acpaas-ui-widgets/nodejs-contact-picker 中文文档教程
Contact Picker Smart Widget BFF (Node)
这是一个 Node.js 后端服务库,用于为 Contact Picker Smart Widget 创建 BFF 服务。 该小部件提供了一个选择器字段,用于从联系人列表中选择一个人。 此服务与相应的 UI 匹配。
有一个演示服务,请参阅下面的运行说明。
How to use
Installing
将此存储库中的 .npmrc 文件复制到应用程序的文件夹中。
然后安装(您需要在 digipolis 网络上):
> npm install @acpaas-ui-widgets/nodejs-contact-picker
Using
Express 示例:
const express = require('express');
const app = express()
const pickerHelper = require('@acpaas-ui-widgets/nodejs-contact-picker');
const controller = pickerHelper.mprofiel.createController({
clientId: "<oauth client id>",
clientSecret: "<oauth client secret>",
oauthUrl: "https://api-gw-o.antwerpen.be/astad/mprofiel/v1/oauth2/token",
serviceUrl: "https://api-gw-o.antwerpen.be/astad/mprofiel/v1/api/mprofiel"
});
app.get('/api/medewerkers', controller);
app.listen(3000);
您可以通过在 API 商店。
该库提供以下接口:
- mprofiel
- createController(config): create an express controller that handles the connection to the mprofiel API
- createService(config): create a function that accepts a query and returns a promise of the results of the mprofiel API for that query. The createController routine builds on top of this.
Run the demo app
创建一个包含以下内容的 .env 文件:
PORT=3000
OAUTH_CLIENT_ID=<client id>
OAUTH_CLIENT_SECRET=<client secret>
MPROFIEL_OAUTH_URL=https://api-gw-o.antwerpen.be/astad/mprofiel/v1/oauth2/token
MPROFIEL_API_URL=https://api-gw-o.antwerpen.be/astad/mprofiel/v1/api/profiles
通过在 上的 mprofiel 服务上创建合同来获取客户端 ID 和客户端密码api-store-o.antwerpen.be。
创建具有正确权限的服务帐户:在用户管理引擎(应用程序 Digipolis --> MPROFIEL)中请求权限。
(删除 URL 中的 -o 扩展名以使用生产 api。)
运行服务:
> npm install
> npm start
通过浏览到 localhost:3000/ 进行测试api/medewerkers?search=aa.
UI 演示应用程序期望该服务在端口 3000 上运行。
Service Specification
该服务实现以下协议:
- GET /path/to/endpoint?search=…
- search = the text that the user typed on which to match
- result = JSON-encoded array of ContactItem objects
包含一个 example swagger description。
Contributing
我们欢迎您的错误报告和拉取请求。
请参阅我们的贡献指南。
License
该项目根据 MIT 许可发布。
Contact Picker Smart Widget BFF (Node)
This is a Node.js backend service library to create a BFF service for the Contact Picker Smart Widget. The widget provides a picker field to choose a person from a list of contacts. This service is matched by a corresponding UI.
There is a demo service, see below for instructions on running it.
How to use
Installing
Copy the .npmrc file from this repo to your application's folder.
Then install (you will need to be on the digipolis network):
> npm install @acpaas-ui-widgets/nodejs-contact-picker
Using
Express example:
const express = require('express');
const app = express()
const pickerHelper = require('@acpaas-ui-widgets/nodejs-contact-picker');
const controller = pickerHelper.mprofiel.createController({
clientId: "<oauth client id>",
clientSecret: "<oauth client secret>",
oauthUrl: "https://api-gw-o.antwerpen.be/astad/mprofiel/v1/oauth2/token",
serviceUrl: "https://api-gw-o.antwerpen.be/astad/mprofiel/v1/api/mprofiel"
});
app.get('/api/medewerkers', controller);
app.listen(3000);
You can obtain the OAuth credentials by taking a contract on the API in the API store.
The library provides the following interface:
- mprofiel
- createController(config): create an express controller that handles the connection to the mprofiel API
- createService(config): create a function that accepts a query and returns a promise of the results of the mprofiel API for that query. The createController routine builds on top of this.
Run the demo app
Create a .env file containing:
PORT=3000
OAUTH_CLIENT_ID=<client id>
OAUTH_CLIENT_SECRET=<client secret>
MPROFIEL_OAUTH_URL=https://api-gw-o.antwerpen.be/astad/mprofiel/v1/oauth2/token
MPROFIEL_API_URL=https://api-gw-o.antwerpen.be/astad/mprofiel/v1/api/profiles
Obtain the client id and client secret by creating a contract on the mprofiel service on api-store-o.antwerpen.be.
Create a service account with the correct permissions: request permissions in the User Management Engine (application Digipolis --> MPROFIEL).
(Remove the -o extension in the URL's to use the production api.)
Run the service:
> npm install
> npm start
Test by browsing to localhost:3000/api/medewerkers?search=aa.
The UI demo app expects the service to run on port 3000.
Service Specification
The service implements the following protocol:
- GET /path/to/endpoint?search=…
- search = the text that the user typed on which to match
- result = JSON-encoded array of ContactItem objects
An example swagger description is included.
Contributing
We welcome your bug reports and pull requests.
Please see our contribution guide.
License
This project is published under the MIT license.