sequelize.jsfeathersjs

Feathersjs logger and hooks


Using FeathersJS and Sequelize-MariaDB for this particular App. The DB and Service seem OK from the basic FeathersCLI initialisation

We then remove the logger module and replace it with our in-house version called "logger" but in ../src/utils/logger.js

We add a before-create hook to validate incoming POST data and add backend fields to the data.

We also add an additional before-find hook which checks for additional authorization returning a 401 if not given. These are the only hooks on this service (no other hooks yet on any other service.

We test using Postman.

The create hook seems to work well producing valid records in the db.

However, A get (ie. list) request returns with a

   {
        "name": "GeneralError",
        "message": "logger is not a function",
        "code": 500,
        "className": "general-error",
        "data": {},
        "errors": {}
    }

the above message does no make sense! Our logger function works perfectly when called. We have tested that in ../app and in the ../src/services/myservice/myservice.service and in the two hooks and is not called anywhere else in our codebase.

So where is the above error coming from? Is some other node_module triggering it? (outside our control)


Solution

  • sort of solved (well not really) but must get on, so we have removed logger.js from app so the error goes away and replaced with good old console.log() when needed. so we can also remove winston which I've never been a fan of ...