refactor(daemon): Enclose facet maker
MODIFY
packages/daemon/daemon.js
packages/daemon/daemon.js
@@ -24,6 +24,10 @@ const sinkError = error => {
console.error(error);
};
+/**
+ * @param {import('./index.js').Locator} locator
+ */
+const makeEndoFacets = locator => {
const publicFacet = Far('Endo public facet', {});
const privateFacet = Far('Endo private facet', {
@@ -33,11 +37,14 @@ const privateFacet = Far('Endo private facet', {
},
});
-const bootstrap = harden({
+ const endoFacet = harden({
publicFacet,
privateFacet,
});
+ return endoFacet;
+};
+
export const main = async () => {
process.once('exit', () => {
console.error('Endo exiting');
@@ -54,6 +61,10 @@ export const main = async () => {
const sockPath = process.argv[2];
const endoPath = process.argv[3];
+ const locator = { sockPath, endoPath };
+
+ const endoFacets = makeEndoFacets(locator);
+
await fs.promises.mkdir(endoPath, { recursive: true });
const server = net.createServer();
@@ -76,7 +87,7 @@ export const main = async () => {
process.exit(-1);
});
server.on('connection', conn => {
- const { drained } = makeCapTPWithConnection('Endo', conn, bootstrap);
+ const { drained } = makeCapTPWithConnection('Endo', conn, endoFacets);
drained.catch(sinkError);
});

refactor(daemon): Enclose facet maker