Socket
Socket
Sign inDemoInstall

hapi-decorators

Package Overview
Dependencies
14
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.2 to 0.2.3

.babelrc

7

index.js

@@ -23,3 +23,3 @@ 'use strict'

if (!this.rawRoutes) {
return
return []
}

@@ -41,2 +41,5 @@

return function (target, key, descriptor) {
var targetName = target.constructor.name
var routeId = targetName + '.' + key
setRoute(target, key, {

@@ -46,3 +49,3 @@ method: method,

config: {
id: key
id: routeId
},

@@ -49,0 +52,0 @@ handler: descriptor.value

{
"name": "hapi-decorators",
"version": "0.2.2",
"version": "0.2.3",
"description": "",

@@ -8,5 +8,5 @@ "main": "index.js",

"lint": "snazzy index.js",
"test": "node test | tap-spec",
"test": "babel-node test/*.js | tspec",
"posttest": "npm run lint",
"coverage": "babel-node node_modules/.bin/isparta cover test/*.js",
"coverage": "babel-node node_modules/.bin/isparta cover test/*.js | tspec",
"coveralls": "npm run coverage -s && coveralls < coverage/lcov.info",

@@ -28,2 +28,3 @@ "postcoveralls": "rimraf ./coverage"

"coveralls": "^2.11.4",
"isparta": "^3.0.4",
"rimraf": "^2.4.3",

@@ -30,0 +31,0 @@ "snazzy": "^2.0.1",

'use strict'
require('babel/register')({
optional: ['es7.decorators', 'es7.objectRestSpread']
var test = require('tape')
var NoRoutes = require('./fixtures/no-routes')
var web = require('../')
@web.controller('/check')
class Check {
@web.route('get', '/in')
@web.validate({ payload: true })
checkIn(request, reply) {
}
}
test('instance has routes function', function (t) {
let check = new Check()
t.ok(typeof check.routes === 'function', 'Has `routes` function')
t.end()
})
require('./controller')
test('instance has no routes', function (t) {
let instance = new NoRoutes()
t.same(instance.routes(), [], 'No routes returns empty array')
t.end()
})
test('instance generates routes array', function (t) {
let check = new Check()
var results = check.routes()
t.ok(Array.isArray(results), 'results is an array')
t.equal(results.length, 1, 'Has one result')
let first = results[0]
t.equal(first.method, 'get', 'method is get')
t.equal(first.path, '/check/in', 'path is merged with controller path')
t.equal(typeof first.handler, 'function', 'handler is a function')
t.same(first.config, { id: 'Check.checkIn', bind: check, validate: { payload: true } }, 'Config is valid')
t.end()
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc