Skip to content

A stand-alone version of Expressive for Express middleware. [Create express routes from an object!]

License

Notifications You must be signed in to change notification settings

ExpressiveJS/expressive-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

expressive-middleware

A stand-alone version of Expressive.js for Express middleware. [Create express routes from an object!]
You may be looking for Express plugin for Expressive.js

Install:

npm install https://github.com/bugs181/expressive-middleware/ --save

Use:

const expressive = require('expressive-middleware')
const app = require('express')()

app.use(expressive(routes))
app.listen(80)

Routes Example:

const routes = {
  user: function(name, callback) {
    callback(null, `Username: ${name}`)
  },
}

CRUD-L (Create, Read, Update, Delete, List) example:

const routes = {
  users: {
    create: function(user, password, callback) {

    },

    read: function(user, callback) {
      callback(null, 'OKAY')
    },

    ...
  },
}

Custom CRUD-L terms:

const terms = {
  verbs: {
    create: 'post',
    read: 'get',
    update: 'put',
    delete: 'delete',
    list: 'options',
  }
}

const routes = {
  users: {
    post: createUser, // Function
    get: getUser, // Function
    ...
  }
}

...

app.use(expressive(routes, terms))

Other config options:

const config = {
  statusInResponse: true, // If data is JSON, sends status code along with data.
  routeNotFound: '404', // Can be a 404.html file. fs.fileSync('404.html')
}

...

app.use(expressive(routes, config))

Documenttion:

The full routing capabilities of Expressive can be found here:
Expressive Documentation


License:

About

A stand-alone version of Expressive for Express middleware. [Create express routes from an object!]

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published