Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yite

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yite

A web framework for Node.js called Yite.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

YiteWeb Framework for Node.js

A lite web framework for Node.js called Yite. This framework helps to create web pages and web applications with Javascript in Controller-View Pattern.

Installation

$ npm install yite

Get Started

app.js
var http = require('http');
var yite = require('yite');

yite.config({
  templateEngine: 'swig',
  errorFilePath: __dirname + '/views/error.html',
  controller: __dirname + '/controller',
  viewsRoutes: __dirname + '/view-paths'
});

http.createServer(function (request, response) {
  yite.init(request, response);
}).listen(3000);

The application will listen on 3000. The yite will use some configs to set the application. It will set template engine, controller file path, viewRoutes file path, error file path etc in application. The yite supports swig, jade and ejs template engines.

controller.js
module.exports = (function () {
  var _index = function(reqMethod, params) {
    return {
      pagename: 'awesome people',
      authors: ['Paul', 'Jim', 'Jane']
    };
  }, _add = function(reqMethod, params) {
    return {
      pagename: 'awesome people',
      authors: ['Paul', 'Jim', 'Jane']
    };
  };

  return {
    index: _index,
    add: _add,
  }
})();

The controller file will return method to each request. Each method will have first argument as request method(GET or POST) and second argument as parameters passed in GET and POST request. Two more arguments(request and response objects) are given optionally, if end user needs any alternation in request and response handling. For example, The http://localhost:3000/add request url will attach to add method in controller. We should specify the each method in controller file for each request(GET & POST). We can override the default controller file path in yite configs.

view-paths.js
module.exports = function (url, viewsHTMLPaths) {
  var routeHTMLs = {
    '/'     : '/views/index.html',
    '/add'  : '/views/add.html',
    '/home' : '/views/home.html'
  };
  return viewsHTMLPaths.set(url, routeHTMLs);
};

The view-paths file is used to map request route to HTML file. For example, The http://localhost:3000/add will attach to add.html HTML file in views. We can override the default view-paths file in yite configs.

By using above files we can start to create an application.

An demo application is given with examples.

Yite is still an experimental version. Want to improve the yite stuff, please don't hesitate. Make a Pull Request or create an issue.

License

The MIT License (MIT)

Copyright (c) 2014 Justin John Mathews justinjohnmathews@gmail.com

Keywords

FAQs

Package last updated on 21 Jul 2014

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