New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koaw

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koaw - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

20

lib/index.js

@@ -277,2 +277,3 @@ 'use strict'

_route (method, path, handler) {
let orm = this.orm
let model = this._getModel()

@@ -285,5 +286,11 @@ let defaultHandlers = this._handlers

if (path === '/' || path === '/:id') {
// Add body params validation
args.push(function *(next) {
// Add properties to middleware flow
args.push(function *(next) {
this.waterline = orm
yield next
})
// Add body params validation
args.push(function *(next) {
if (path === '/' || path === '/:id') {
let body = this.request.body

@@ -294,6 +301,7 @@

}
yield next
})
}
}
yield next
})
// Add before middlewares

@@ -300,0 +308,0 @@ if (beforeFns && beforeFns[method] && beforeFns[method].length) {

{
"name": "koaw",
"version": "0.4.0",
"version": "0.4.1",
"description": "Create APIs using Koa and Waterline",

@@ -5,0 +5,0 @@ "main": "./lib",

@@ -8,3 +8,5 @@ 'use strict'

const server = require('../fixtures/server')
const sinon = require('sinon')
const waterline = require('../fixtures/waterline')
const Waterline = require('waterline')

@@ -85,2 +87,37 @@ describe('server', function () {

})
it('should set waterline object to middlewares', function *() {
let spy = sinon.spy()
let handler = function *(next) {
spy(this.waterline)
this.status = 200
yield next
}
let controller = new Koaw({
orm: this.waterline,
model: 'store'
})
controller
.override('get put post delete', handler)
.route('get put delete', '/nested/123', handler)
.register(this.server)
yield this.agent.post(controller._path).send(this.params)
yield this.agent.get(controller._path)
yield this.agent.get(`${controller._path}/123`)
yield this.agent.put(`${controller._path}/123`).send(this.params)
yield this.agent.delete(`${controller._path}/123`)
yield this.agent.get(`${controller._path}/nested/123`)
yield this.agent.put(`${controller._path}/nested/123`)
yield this.agent.delete(`${controller._path}/nested/123`)
assert.equal(spy.callCount, 8)
for (let i = 0; i < spy.callCount; i++) {
assert(spy.args[i][0], 'waterline object does not exists!')
assert(spy.args[i][0] instanceof Waterline)
}
})
})
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc