Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appa

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appa

Quickly create simple JSON API services.

  • 5.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

appa

Quickly create simple JSON API services.

Travis npm

appa

Install

Make sure you've got node installed, then make appa a project dependency:

npm install --save appa

Minimal example

var http = require('http')
var app = require('appa')()

app.on('/', function (req, res, context) {
  app.send(res, { message: 'oh hey friends' })
})

http.createServer(app).listen(3000, function () {
  app.log.info('server started at http://127.0.0.1:3000')
})

API

createApp

Create the application. Returns the app function that can be passed into http.createServer.

Parameters

  • options Object

app

The request, response handler that is passed to http.createServer, and the object that provides methods for your app.

Parameters

  • req Object – the http request object
  • res Object – the http response object

app.on

Route handler

Parameters

  • pathname String – the route for this handler
  • callback Function – the route handler

app.send

Send a JSON object as a response

Parameters

  • res Object – the http response object
  • statusCode Number – the status code of the response, default is 200
  • data Object – the data that will be stringified into JSON

app.error

Send a JSON error response

Parameters

  • response Object – the http response object
  • statusCode Number – the status code of the response, default is 404
  • message String – the message that will be stringified into JSON
  • data Object – additional data about the error to send in the response

app.log

Create logs using the pino module: https://npmjs.com/pino

app.json

Parse or stringify a JSON stream using the JSONStream module: https://npmjs.com/JSONStream

app.pipe

Compose a stream using the pump module: https://npmjs.com/pump

License

MIT

FAQs

Package last updated on 26 Jul 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc