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

bonera

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bonera

minimalist web framework for node.js

  • 1.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Bonera Web Framewor

Minimalist web framework for node.js

Installation

$ npm install bonera

Features

  • Use middlewares
  • Get
  • Put
  • Patch
  • Post
  • Delete
  • Liste
create a middleware
app.use((req, res) => {
  //create the middleware to use
})
access the params of the url using
req.params
access the query of the url using
req.query
access the form of the post using
req.body
get
app.get('/path', callback)
put
app.put('/path', callback)
patch
app.patch('/path', callback)
post
app.post('/path', callback)
delete
app.delete('/path', callback)
start the server
app.listen(port, callback)
e.g

const bonera = require('bonera');
const app = bonera();

//Create a middleware to display the respond as a JSON
app.use((req, res) => {
  res.json = (val) => res.end(JSON.stringify(val));
});

app.get('/', (req, res) => {
  console.log('Hello world');
});

//if the path is /user/?message=Hello-world
app.get('/greet', (req, res) => {
  console.log(`The message ${req.query.message}`);
});

app.get('/user/:id', (req, res) => {
  console.log(`The user id is ${req.params.id}`);
});

app.post('/user', (req, res) => {
  console.log('A post has been made, use req.body to access to the data')
});

app.put('/user/:id', (req, res) => {
  console.log('A put has been made, access to the params with req.params.id');
});

app.patch('/user/:id', (req, res) => {
  console.log('A patch has been made, access to the params with req.params.id');  
});

app.delete('/user/:id', (req, res) => {
  console.log('A delete has been made, access to the params with req.params.id');
});

app.listen(8080, () => {
  console.log('server running on port 8080')
})

Keywords

FAQs

Package last updated on 04 Jul 2017

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