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

accounts-api

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accounts-api

An accounts api that follows a few contraints to try and make it easy to plug into a node http server

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by600%
Maintainers
1
Weekly downloads
 
Created
Source

accounts-api

This app follows a few constraints to try and make it easy to plug into a node http server.

The goal is a simple API resource that can be used on its own or in other servers.

The file organization and approach is inspired in part by django's idea of apps.

Usage

To use it, you'd include it in the server like this:

var http = require('http')
var response = require('response')
var levelup = require('levelup')
var db = levelup('db', { db: require('memdown') })

var server = http.createServer(function (req, res) {
  /* 
  * if req.url matches a route, it will return, 
  * otherwise, another part of the application can respond 
  */
  this.db = db
  var accounts = requires('accounts-api')(this)
  if (accounts.serve(req, res)) return
  response().json({ message: 'hi' }).pipe(res)
})

server.listen(4444)

Todo

  • decide how to handle static assets, and how they might be handled across the application

Structure

  • index.js
    • this module provides the model, handler, and routes modules of the app
    • it also provides a serve method that is used to match req.url to the app's routes
  • routes.js
    • a simple router that takes the handler as an argument, and matches routes to handler methods
  • handler.js
    • takes the model as an argument, and parses requests to perform operations with the model
  • model.js
    • provides CRUD and other necessary actions like validation, indexing, etc. This is based on accountdown and leveldb.

Keywords

FAQs

Package last updated on 14 Jul 2015

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