Socket
Socket
Sign inDemoInstall

api-srv

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    api-srv

Node.js JSON-API server


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Install size
196 kB
Created
Weekly downloads
 

Readme

Source

api-srv

Node.js JSON-API server

Install

$ npm install api-srv

Fast start

Simple configurating

var ApiSrv = require('api-srv')

var Srv = ApiSrv.extend({
	routes: {
		"/": {
			"GET": "main"
		}
	},
	main: function(request){
		request.response({
			code: 200,
			body: '{"success": true, "text": "Hello world!"}'
		});
	}
});

new Srv({port: 8000});

Options

  • Number port — Server port, default 8000
  • String host — Server host, default "0.0.0.0"
  • Number timeout — Request timeout, trfault 30000 (30 sec)
  • Object corsCORS settings
    • Boolean enabled — CORS enabled flag, default true
    • String allowOrigin — Value of Access-Control-Allow-Origin header, default "*"
    • String allowHeaders — Value of Access-Control-Allow-Headers header, default "origin, authorization, content-type, accept"
    • String allowMethods — Value of Access-Control-Allow-Methods header, default "POST, GET, OPTIONS, PUT, DELETE"

Keywords

FAQs

Last updated on 08 Apr 2015

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