New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

sinodetra-you-goto-my-head

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sinodetra-you-goto-my-head

Minimal Sinatra like router for node.js by fapprik... with the added ability to respond with custom headers


Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created

sinodetra-you-goto-my-head

Minimal Sinatra like router for node.js by fapprik... with the added ability to respond with custom headers

Installation

npm install sinodetra-you-goto-my-head

Usage

At first, (install and) require sinodetra-you-goto-my-head within your script and specify your preferred port (8000 in this example).

var app = require('sinodetra-you-goto-my-head')(8000)

You can refer to Sinodetra README for a better idea on usage

Examples

app.get('/', function(request, response) {
	response.plain('Hello world!')
})

app.get('/say/:greeting/to/:person', function(request, response, greeting, person) {
	response.html('<b>' + greeting + '</b>, ' + person + '!')
})

app.get('/([0-9]+)/plus/([0-9]+)', function(request, response, one, two) {
	response.plain((parseInt(one, 10) + parseInt(two, 10)).toString())
})

app.error(function(request, response) {
	response.plain('404')
})

// In order to resolve the CORS error when running the server locally
app.get('/healthcheck', (request, response) => {
  console.log(request)
	response.send(
    {active: true},
    200,
    'application/json',
    {'Access-Control-Allow-Origin': "*", 'Access-Control-Allow-Methods': 'POST, GET, PUT, DELETE'}
  )
})  

Contributors

FAQs

Package last updated on 08 Mar 2018

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