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

express-routes-mapper

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-routes-mapper - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

2

package.json
{
"name": "express-routes-mapper",
"version": "0.0.5",
"version": "0.0.6",
"description": "a small mapper for express routes",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

# express-routes-mapper
## a simple package to map your routes for your expressjs application
> a simple package to map your routes for your expressjs application
## Getting started
- [Start from ground](#start-from-ground)
- [supported methods](#supported-methods)
- [dynamic routes](#dynamic-routes)
## Start from ground
This is a example for a simple rest API.

@@ -48,3 +54,3 @@

create (req,res) {
create (req, res) {

@@ -60,3 +66,3 @@ res.send('created a User with es6');

'create': function(req,res){
'create': function (req, res) {

@@ -113,3 +119,3 @@ res.send('created a User with es5');

const server = http.Server(app);
const port = 4444;
const port = 3338;

@@ -132,3 +138,3 @@ app.use('/', mapRoutes(routes));

var server = http.Server(app);
var port = 4444;
var port = 3339;

@@ -140,3 +146,58 @@ app.use('/', mapRoutes(routes));

console.log('Gladly listening on http://127.0.0.1:' + port);
})
});
```
## Supported methods
* GET
* POST
* PUT
* DELETE
```js
{
'GET /someroute' : 'SomeController.somefunction',
'POST /someroute' : 'SomeController.somefunction',
'PUT /someroute' : 'SomeController.somefunction',
'DELETE /someroute' : 'SomeController.somefunction'
}
```
## Dynamic routes
Simply use a colon ':' for defining dynamic routes.
```js
{
'GET /someroute/:id' : 'SomeController.somefunction'
}
```
If you make a get request to `http://localhost/someroute/1` the 1 (:id) is now in the 'SomeController accessible.
```js
//es6
export default class SomeController {
somefunction (req, res) {
let id = req.params.id;
}
}
//es5
module.exports = {
'somefunction': function (req, res) {
var id = req.params.id
}
}
```

Sorry, the diff of this file is not supported yet

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