openvibers/openvibe.connect Commits

Mount the agent layer after the share-host middleware, not inside it (SEO-2) (#27)

OP OpenVibers committed 10 days ago · 27ca01b4a6 · 2 files, +7 −1

#26 put the mount inside the middleware after its return, so it never ran and
/.well-known/agent.json stayed 404. The page test now requests it.

Changes

ddiff --git a/server/app.js b/server/app.js
iindex d343e55..56a2100 100644
---- a/server/app.js
++++ b/server/app.js
@@@ -159,10 +159,10 @@ async function createApp(opts = {}) {
log.error('[OpenVibe.Connect] share request failed:', err && err.message);
if (!res.headersSent) { res.statusCode = 502; res.end('Something went wrong on our side.'); } else res.destroy();
});
++ });
// /.well-known/agent.json (openvibe-shared/agent-layer, SEO-2): what this site serves, for agents.
// After the share hosts: a share's own /.well-known/agent.json belongs to the share.
require('openvibe-shared/agent-layer').mount(app, { descriptor: require('./agent-descriptor') });
-- });
const release = require('openvibe-shared/release').createRelease({ service: 'connect', root: path.join(__dirname, '..') });
setRelease(release.release);
ddiff --git a/test/pages.test.js b/test/pages.test.js
iindex 453583b..2b758f7 100644
---- a/test/pages.test.js
++++ b/test/pages.test.js
@@@ -100,6 +100,12 @@ const { check, done } = require('./helpers/check');
await check('robots, llms.txt and the client download', async () => {
assert.match((await t.get('/robots.txt')).text, /Disallow: \/grant/);
assert.match((await t.get('/llms.txt')).text, /OpenVibe Connect/);
++ // SEO-2: the agent manifest is served (11-03: the mount had landed inside the share-host middleware, after its
++ // return, so it never ran while the source check passed).
++ const agent = await t.get('/.well-known/agent.json');
++ assert.strictEqual(agent.status, 200);
++ const m = agent.json();
++ assert.deepStrictEqual([m.network, m.id, m.home], ['OpenVibe', 'connect', 'https://connect.openvibe.website']);
// SEO-33: llms.txt, then the README (Connect's full documentation).
const full = await t.get('/llms-full.txt');
assert.strictEqual(full.status, 200);