strapi-community/strapi-plugin-io

[Bug]: Export middlewares

MarijnFK opened this issue · 1 comments

What issue are you experiencing?

I'm trying to use the handshake middleware in custom (dynamic) namespaces, but i cannot seem to import it from anywhere.

[2023-01-22 14:40:15.960] error: Cannot find module 'strapi-plugin-io'

./src/index.ts:
`
//can't import anything, module strapi-plugin-io not found
const { middlewares } = require("strapi-plugin-io");

export default {
register(/{ strapi }/) { },

bootstrap({ strapi }) {
strapi.$io.socket.of(/^/\w+$/).use(middlewares.handshake);
},
};

`

Steps To Reproduce

No response

What version of the plugin are you using?

"strapi-plugin-io": "^1.1.4"

What strapi version are you using?

"@strapi/strapi": "4.5.6"

The middlewares are not intended to be exposed, that being said I do not recall why the middlewares default export is an empty object.

This should work

const { handshake } = require("strapi-plugin-io/server/middlewares/handshake");

which for ts should be

import * as middleware from "strapi-plugin-io/server/middlewares/handshake";
const handshake = middleware.handshake;

P.S. This path is not guaranteed to be stable.