Creating the agent
Now we get to the good stuff!
Creating the on-premise agent.
We will need the following pre-requisites:
node v18 or above
npm
Lets start by creating a new directory for our connector and going into it:
~/devel$ mkdir lucy-sqlite-connector
~/devel$ cd lucy-sqlite-connector
Then lets run npm init
to setup a new project. Just accept the defaults
devel/lucy-sqlite-connector$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help init` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
Next, lets install the Lucy node.js sdk package as a dependency.
npm install https://github.com/lucy-connectors/lucy-node-sdk
Lets then create a src
directory to hold our source code and then add a new index.js
file in that directory. That will be the entry point for our code.
devel/lucy-sqlite-connector$ mkdir src
devel/lucy-sqlite-connector$ cd src
lucy-sqlite-connector/src$ touch index.js
lucy-sqlite-connector/src$ code index.js
(The last command assumes you are using Visual Studio Code as your editor - Replace as appropriate)
Lets open the empty index.js
file and add this code:
```javascript
const process = require('process');
const {LucyConnector} = require('lucy-node-sdk');
const ConnectorName='SqliteConnector';
async function processRequest(payload) {
return {"result":[],"count":0};
}
const connector = LucyConnector.fromInstallationKey(process.env.LUCY_CONNECTOR_KEY,ConnectorName,processRequest);
connector.init().then(()=>{
console.log('Connector initialized');
});
```
We'll explain what the code does later.
For now lets just put this in and to get it up and running.
The next step is registering a connector instance and defining our integration.
Last updated