Coder Social home page Coder Social logo

powernerd / node-token-jwt Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 9 KB

Showing my work from https://scotch.io/tutorials/authenticate-a-node-js-api-with-json-web-tokens#toc-authenticating-and-creating-a-token

License: MIT License

JavaScript 100.00%

node-token-jwt's People

Contributors

powernerd avatar

Stargazers

 avatar

Watchers

 avatar  avatar

node-token-jwt's Issues

Needs a test framework and runner

This application needs some sort of a test framework to make sure it's all functioning properly automatically.

Mocha is great, but it lacks on a coverage tool, so you would also need istanbul (nyc) as well.
tap is a really great tester, and nyc coverage is included. I can't really get the mocha-like syntax to work with tap though, so I gave up and have been using Mocha in my projects so far. I'd down to revisit BDD with tap.

Also you need to decide on an assertion library like should.js (others also use chai).

Testing APIs is kinda tricky. You need to wait for a callback with Mocha.

Here is how I test an older SOAP API with Mocha and Should -- note the use of done() here and a module which uses callbacks soapclient.logIn:

it('returns a 36 character token if passed valid credentials', function(done) {
  var args = {
    domain: arg_domain,
    username: arg_user,
    password: arg_pass
  }
  soapclient.logIn(args, function(err, result) {
    should.not.exist(err)
    result['return']['status']['$value'].should.equal('completed')
    admin_token = result['return']['result']['$value']
    console.log(result['return']['message']['$value'] +' token: '+admin_token)
    admin_token.should.have.length(36)
    done()
  })
})

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.