br41nslug / directus-websocket-subscribe

An extension to subscribe to directus updates over a websocket.
MIT License
106 stars 13 forks source link

9.9.1 env is not loaded to setup config #4

Closed MichalNemec closed 2 years ago

MichalNemec commented 2 years ago

Hello, i set on directus 9.9.1 .env properties as your documentation, but they are not loaded. only setting it in config.ts works. Second try was to create a hook

export default ({ filter, action }) => {
    filter('websocket.config', () => {
            cfg.path = '/test'; // Change the websocket path
            cfg.public = true; // Enable public connections to the websocket
            cfg.system.delete = false; // Disable the delete handler
            return cfg;
    });
};

or this does not work.. loading the hook before or after, does not matter.

export default (_, { logger, emitter }) => {
  emitter.onFilter('websocket.config', (cfg) => {
    cfg.path = '/test'; // Change the websocket path
    cfg.public = true; // Enable public connections to the websocket
    cfg.system.delete = false; // Disable the delete handler
    return cfg;
  });
};

module.exports = function registerHook(_, { logger, emitter }) {
  emitter.onFilter('websocket.config', (cfg) => {
    cfg.path = '/test'; // Change the websocket path
    cfg.system = true; // Enable system collection events
    cfg.core.delete = false; // Disable the delete handler
    return cfg;
  });
};
br41nslug commented 2 years ago

Thanks :) I should indeed look into updating

br41nslug commented 2 years ago

Updated the extension-sdk to v9.10.0 and is working in my tests for 9.9.1 too