You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use decorative wrapper in my rest server with node + express, I am trying to create an auth filter that will take a JWT token for all the rest endpoints and de-tokenize it and send the payload back to the method.
I have created a plugin similar to log, mentioned in the readme file. PFB
`var wrap = require('decorator-wrap').wrap;
var log = function (callback, args, name, type){
console.log('Starting ', type, name);
var result = callback();
console.log('Ended: ', name);
return result;
};
module.exports = function(target, key, descriptor) {
return wrap(log)(target, key, descriptor);
}
`
I am importing the plugin in my router as below
`var express = require('express');
var router = express.Router();
var serviceAdapterForSendEmail= require('../ServiceAdapters/SendEmail');
const Post = require("../models/Post")
/* GET home page. */
var request = require('request');
var fs = require('fs');
var log= require('./log');
console.log(log);
@log
router.get('/', function(req, res, next) {
res.send({
"login": "unsuccessful"
});
});
module.exports = router;`
However, when I execute I get the following error
`RestServiceNodeJSForger % npm run start env=local
> [email protected] start /Users/ag33128/CodeBase_Dev/RestServiceNodeJSForger
> node ./bin/www "env=local"
/Users/ag33128/CodeBase_Dev/RestServiceNodeJSForger/routes/index.js:11
@log
^
SyntaxError: Invalid or unexpected token
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/ag33128/CodeBase_Dev/RestServiceNodeJSForger/app.js:7:19)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node ./bin/www "env=local"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ag33128/.npm/_logs/2021-12-09T02_43_36_713Z-debug.log`
Any Pointers will be helpful
The text was updated successfully, but these errors were encountered:
Hi @cmartin81, @sierra-m ,
I am trying to use decorative wrapper in my rest server with node + express, I am trying to create an auth filter that will take a JWT token for all the rest endpoints and de-tokenize it and send the payload back to the method.
I have created a plugin similar to log, mentioned in the readme file. PFB
I am importing the plugin in my router as below
However, when I execute I get the following error
Any Pointers will be helpful
The text was updated successfully, but these errors were encountered: