Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ const susie = require('susie');
await server.register(susie);
✗ const { susie } = require('susie');
Requires CommonJS, as susie is a hapi plugin. No default export for ESM.
h.event()
✓ // Decorated on toolkit after registration
handler: function (request, h) {
return h.event({ data: 'hello' });
}
✗ import { event } from 'susie';
h.event() is not a standalone import; it's added to the hapi response toolkit after registering the plugin.
plugin registration
✓ await server.register({ plugin: require('susie'), options: {} });
✗ server.register({ register: susie, options: {} });
Use the standard hapi plugin pattern. As of hapi v17+, registration must be awaited.
Registers the susie plugin and creates an SSE endpoint that sends 5 events with 1-second intervals, then closes the connection with an 'end' event.
const Hapi = require('@hapi/hapi');
const susie = require('susie');
const start = async () => {
const server = Hapi.server({ port: 3000 });
await server.register(susie);
server.route({
method: 'GET',
path: '/events',
handler: (request, h) => {
const response = h.event({ id: 1, data: 'hello' });
let count = 1;
const interval = setInterval(() => {
count++;
h.event({ id: count, data: `message ${count}` });
if (count >= 5) {
clearInterval(interval);
h.event(null); // sends 'end' event and closes
}
}, 1000);
return response;
}
});
await server.start();
console.log('Server running on', server.info.uri);
};
start();
Errors
Common errors & fixes
Error: h.event is not a function
susie plugin not registered before route handler or incorrect registration.
fixEnsure await server.register(require('susie')); is called before defining routes. TypeError: Cannot destructure property 'susie' of ...
Using named import syntax with require or import on susie.
fixUse const susie = require('susie'); and pass it directly to server.register. Audit
Dependencies
hapirequiredpeer dependency required for plugin registration and toolkit decoration