Socket
Book a DemoInstallSign in
Socket

api-srv

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-srv

Node.js JSON-API server

0.1.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
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

node.js

FAQs

Package last updated on 08 Apr 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.