Skip to content

nmabhinandan/pjax-parser

Repository files navigation

PJAX-Parser

Express middleware to handle pjax requests

npm version Code Climate GitHub license

Installation

npm install pjax-parser --save

Usage

import express from 'express';
import path from 'path';
import bodyParser from 'body-parser';
import pjaxParser from 'pjax-parser';

const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

app.set('view engine', 'hbs');
app.set('views', path.join(__dirname, 'views'));
app.use(express.static(path.join(__dirname, 'public')));

app.use(pjaxParser());

app.get('/', (req, res) => {
  res.render('index', {data: 'test'});
});

app.get('/about', (req, res) => {
  res.render('about', {data: 'test'});
});

app.listen(3000, () => {
  console.log("listening at http://localhost:3000")
});

Development

The source code is in lib dir. Use gulp build to transpile code to ES5 using babel. Use gulp watch to watch for continuous build.

LICENSE

MIT