Skip to content

Fast, experimental, minimalist web framework for node

License

Notifications You must be signed in to change notification settings

Chhekur/untitled-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Untitled-JS

Fast, experimental, minimalist web framework for node.

NPM Version NPM Downloads

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 0.10 or higher is required.

Installation is done using the npm install command:

$ npm install untitled-js

Follow our installing guide for more information.

Features

  • Virtual routing
  • Focus on rapid development
  • MYSQL AutoQuery Generator (untitled-model)
  • View system supporting 3+ template engines
  • Middleware Support
  • Session Support
  • Content negotiation
  • Executable for generating applications quickly

Docs & Community

Security Issues

If you discover a security vulnerability in untitled-js, please see Contact Us.

Quick Start

The quickest way to get started with untitled-js is to utilize the executable untitled-generator to generate an application as shown below:

$ npm install -g untitled-generator

Create the app:

$ mkdir myFirstApp && cd myFirstApp
$ untitled init

Install dependencies:

$ npm install

Start the server:

$ node app.js

Philosophy

The Untitled philosophy is to provide small, robust tooling for HTTP servers, making it a great solution for single page applications, web sites, hybrids, or public HTTP APIs.

Untitled does not force you to use any specific template engine. With support for over 3 template engines. you can quickly craft your perfect framework.

People

The original author of Untitled is [Harendra Chhekur & Pankaj Devesh]

Documentation

Create New Project

$ mkdir MyProject && cd MyProject
$ npm init
$ untitled init
$ npm install

If there is error in any statement #

Creating Server

var untitled = require('untitled-js');
untitled.settings = require('./__settings/settings');
untitled.startServer(8080);
/*
*  or 
*  untitled.startServer();
*  or
*  untitled.startServer(port, host);
* /

Run Server

$ node app.js

Funtions

Creating Page

$ touch HelloWorld.jss

open this file in any text editor

var untitled = requier('untitled-js');
var page = untitled.page();

page.run = function(req,res){
    return true;
}

page.get = function(req,res){
    res.send('Hello world!');
}

module.exports = get;

Handling Requests On Pages

  • page.run = function(req,res){return true;}
  • page.get = function(req,res){}
  • page.post = function(req,res){}

page.run

This is a pre processing function, which invoked before any other function of page. It must return true or false. Further execution of page will continue iff it returns true.

example

page.run = function(req,res){
    
    if(1 + 1 == 2){
        return true;
    }
    res.send('<meta http-equiv="refresh" content="0;URL=http://untitled-js.com" /> ');
    return false;
}

page.get

This function accept get request.

example

page.get = function(req,res){
    var value = req.GET;
    
    res.send('values of all get parameter');
    res.send(JSON.stringify(value));
    
    value = req.GET.get('name');
    res.send('value of specific parameter');
    res.send(value);
    
    value = req.GET['name'];
    res.send('value of specific parameter');
    res.send(value);
}

page.post

This function accept post request.

example

page.post = function(req,res){
    var value = req.POST;
    
    res.send('values of all post parameter');
    res.send(JSON.stringify(value));
    
    value = req.POST.get('name');
    res.send('value of specific parameter');
    res.send(value);
    
    value = req.POST['name'];
    res.send('value of specific parameter');
    res.send(value);
}

Rendering Templates

res.render(filename, options);
    filename = '*.jade' || '*.ejs' || '*.html';

Ex:
// res.render('template/error_log.jade',{title:error});

Redirect Url's

example

res.redirect('https://google.com');

Session Handling

req.session.put(key,value) Put value in session

example

req.session.put('name','Alex');

req.session.get(key) Get value from session

example

var name = req.session.get('name');

Url Management

In home directory of you project you'll find url.json

example

{
  "/login" : "/front/login.ejs",
  "/register" : "/back/register.jss",
}

here left side you just have to write virtual path that you want to locate your original path defined on righ side

Static File Management

you can save your all static files inside the static folder, then it'll not gonna execute

Middlewares

you can define you own middlewares and save them in folder named middlewares or chage the directory in settings, in case you want

Security

if you want to restrict some files or directory to user access from browser.
you can just simply add __ at the string of that file or directory

example:
__settings, __index.html

Settings

var path = require('path');
module.exports = {

	HOST:"127.0.0.1", // Default Host
	PORT:"3000", // Default Port
	DEBUG:true, // Debugging Mode

	SESSION:true, // Enabled Session

	DATABASE : {
		default:{
			host: "localhost",
		    user: "root",
		    password: "",
		    database:"test"
		}
	}, // Default Database Settings


	HOME_PAGE: 'template/index-1.jade', // Home Page


	MIDDLEWARES : [
		'middlewares/favicon',
		'middlewares/check_user',
		'middlewares/access_denied'
	],  // MIddlewares

	MODEL_DIR  : path.join(__dirname, '..' , 'models'), // Path of models
	STATIC_DIR : path.join(__dirname, '..' , 'static'), // Path of static files 
	BASE_DIR : path.join(__dirname, '..' ), // Path of root directory

	ERROR_PAGE : 'template/error_log.jade', // Error Page

	TEMPLATES_DIR : path.join(__dirname, '..' ,'template'), // Path of Template

	URL_REWRITE_FILE : path.join(__dirname,'..') // Path of urls

}

License

MIT

About

Fast, experimental, minimalist web framework for node

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published