taurus-express-light

0.1.45 • Public • Published

taurus-express-light

A light-weight web server.

Installation

 npm install taurus-express-light.

Usage

Functional example:

var TEL=require('taurus-express-light'),
    _tel=new TEL();

//set application path
_tel.path();

//set the index file. By default the "index.html" 
_tel.index();

//set the pre-function. This function will be called prior to all other middlewares for any requests.
_tel.pre();

//set the static resource
_tel.static('/url-path','./static-resource-path-in-the-root', /*pre-request-function*/ function(){...});

//set POST path
_tel.post('/post-url-path',function(){...},[function(){...},[function(){...}]]);

//set GET path
_tel.get('/get-url-path,function(){...},[function(){...},[function(){...}]]);

//set PUT path
_tel.put('/put-url-path,function(){...},[function(){...},[function(){...}]]);

//set DELETE path
_tel.del('/del-url-path,function(){...},[function(){...},[function(){...}]]);

//persist session details
_tel.setClientInfo(request,/*session detail object*/{client:{..}});

//retrieve current session details
var sessionDetail=_tel.getClientInfo(request);

//set the session/cookie expired and remove the runtime client information.
_tel.removeClientInfo(request);

//data upload multiparts/form
_tel.post('/fileUpload',function(request,response,next){
  var _fs=require('fs');
  var _files=request.body.files;
  _files[0].fileStream.pipe(_fs.createWriteStream(_files[0].fileName));
  res.writeHead(201,{"content-type":"application/json"});
  return response.end(JSON.stringify({status:'ok'}));
});

//path name params matching
_tel.get('/this/:s1/is/:s2/you/:s3/path',function(request,response,next){
  response.writeHead(200,{'content-type':'application/json'});
  return response.end(JSON.stringify({status:'ok', params:{s1:request.params.s1,s2:request.params.s2,s3:request.params.s3}));
});

//Current settings information
_tel.get('/settings',function(request,response,next){
  var settings=_tel.info();
  response.writeHead(200,{'content-type':'application/json'});
  return response.end(JSON.stringify({status:'okay',info:settings}));
});

//Begin listening on port# 3131
_tel.listen(3131);

Function definition:

function(request,response,next){
...
...
}

Authentication:

function(request,response,next){
...
//This will stop executing any chained middlewares.
request.isAuthenticated=false;
...	
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.45
    2
    • latest

Version History

Package Sidebar

Install

npm i taurus-express-light

Weekly Downloads

40

Version

0.1.45

License

MIT

Last publish

Collaborators

  • kyasuda2003