powernerd / node-token-jwt Goto Github PK
View Code? Open in Web Editor NEWShowing 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
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
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()
})
})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.