Coder Social home page Coder Social logo

decorator-wrap's People

Contributors

cmartin81 avatar sierra-m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

decorator-wrap's Issues

SyntaxError: Invalid or unexpected token, Unable to use plugin with express

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

`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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.