Socket
Socket
Sign inDemoInstall

cf-crud-service-api-builder

Package Overview
Dependencies
7
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cf-crud-service-api-builder

Build an HTTP API for a crud-service


Version published
Weekly downloads
98
increased by40%
Maintainers
2
Install size
2.02 MB
Created
Weekly downloads
 

Readme

Source

cf-crud-service-api-builder

Build an HTTP API for a crud-service.

Installation

npm install --save cf-crud-service-api-builder

Usage

const crudServiceApiBuilder = require('cf-crud-service-api-builder')
const router = require('express')()
const logger = require('bunyan').createLogger()
const service = require('./service')
const middleware = require('./auth-check-middleware')

crudServiceApiBuilder(service, '/widgets', router, logger, middleware)

Hooks

When using the api builder, you can hook into certain actions to manipulate the request data before it is sent to the database or the response data before it is sent to the requester.


const api = crudServiceApiBuilder(service, '/article', router, logger, middleware)

api.hook('create:request', function (data, cb) {
  // do whatever you like with the data
  cb(null, data)
})

Supported hooks are:

  • create:request
  • create:response
  • read:response
  • update:request
  • update:response
  • partialUpdate:request
  • partialUpdate:response

Events

When using the api builder, you can listen for certain events so that you can add hooks to perform your own actions after a request has been succesful. e.g


const api = crudServiceApiBuilder(service, '/article', router, logger, middleware)

api.on('create', function (req, newArticle) {
  // do whatever you like with the req and article object
})

Supported events are:

  • create
  • update
  • partialUpdate
  • delete

Credits

Built by developers at Clock.

Licence

Licensed under the ISC

FAQs

Last updated on 13 Feb 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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