JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q53510F
  • License MIT

Super fast and simple web framework for node.js

Package Exports

  • flickerjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (flickerjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Flicker.js

A Super fast and simple web framework for node.js based on Express.

Install

$ npm install flickerjs

Quick Use

var flicker = require('flickerjs');
var app = flicker();

app.use('/', (req, res) => {
    res.send('Hello Flicker.js');
});

app.listen(3000);

Run your app and visit http://localhost:3000/

Example

var flicker = require('flickerjs');
var favicon = require('serve-favicon');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var compress = require('compression');
var app = flicker();

var router = app.Router();

//middlewares
app.use(compress());
app.use(favicon('./public/favicon.ico'));
app.use(app.serveStatic());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());


app.use( (req,res,next) => {
        // middleware work in each request
        res.locals = "Mustang";
        next();
    }
);


router.get('/', (req,res) => {
    console.log(`I receive ${res.locals}`); /* -> Mustang */
    res.template('/index.html');
});

router.get('/form', (req,res,next) => {
    res.template('/form.html');
    next();
});

router.post('/form',(req,res,next) => {
    res.json(req.body);
});


app.use(
    (req,res) => {
        // if app does not found routers, call this middleware.
        res.status(404).template("/404.html");
    }
);


app.use(
    (req,res, next, err) =>{
    // if last param is an error
        res.status(err.status || 500);
        res.send(err.message);
    }
);

app.listen(3000);