Skip to content

Sinodetra server by fapprik with the added ability to respond with custom headers

License

Notifications You must be signed in to change notification settings

aruiz-caritsqa/sinodetra-you-goto-my-head

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Sinodetra server by fapprik with the added ability to respond with custom headers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published