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

express-page

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-page

Simple webpage controllers for Express.

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

express-page

Simple webpage controllers for Express.

Provides a Page object context for your controller with the following properties:

  • this.req
  • this.res
  • this.accessDenied()
  • this.css[]
  • this.js[]
  • this.notFound()
  • this.params
  • this.redirect()
  • this.render()
  • this.setView()
  • this.setLayout()
  • this.templates

Install

npm install express-page

Basic example

var express = require('express')
var Page = require('express-page')
var app = express()
var db = {
  count: 0
}
var controller = function() {
  this.db.count++
  this.res.send('Count is ' + this.db.count)
}

app.get('/example', function(req, res) {
  var page = Page(controller, {
    db: db
  }, req, res)
  page.run()
})

Dynamic routing based on file scan

var express = require('express')
var scan = require('sugar-glob')
var Page = require('express-page')
var app = express()

scan({
  dir: './pages'
})
.file('*index.js', function(file) {
  var uri = '/' + file.dir
  app.get(uri, function(req, res) {
    var controller = require(file.filename)
    var page = Page(controller, {}, req, res)
    page.run()
  })
})

Keywords

FAQs

Package last updated on 05 Mar 2015

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