0.2.1 • Published 8 years ago

slashless v0.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

#Slashless This repository is still in progress. Wildcards are not fully supported.

##Table of Contents

##Instalation Instructions To install this package using npm. Go to the project directory and type: npm install slashless --save

##About the project The is a simple quick launch framework for developing RESTful web applications. The structure promotes modularity by following a resource tree structure with the root resource being the parent of all resources. Resource objects can have children resources. If the parent route doesn't match the URL of the request, it will check for children resources.

##Quick Start To include in a project, var slashless = require('slashless');

###Hello World

var Slashless = require('../lib/slashless');

var app = new Slashless();

var helloWorld = app.root.add('helloWorld');

helloWorld.read(function (req, res) {
  res.write('Hello World');
  res.end();
});

app.listen(3000);

##Objects

  • Slashless(): Slashless is a wrapper around an instance of the http server module.
    • Properties:
      • server: A generic http server. That processes the resources.
      • root: A root resource that had no parent resource. It is the head of all subsequent resources. All children should have this root as their parent resource. If you would like to change the default root pass an argument into the add resource name.
    • Methods
      • listen(port, callback) Sets the server to listen on the provided port.
  • Resource(name, parent, wildCard): This is the core of the slashless framework. The resource object consists of a noun with multiple verbs attached to it. The verbs each correspond to an HTTP verb and a database operation. All supported verbs for a resource are defined in the methods property.
    • Properties
      • children: An object that contains all resources that are children to this resource.
      • methods: The methods object contains a record of which HTTP requests are supported for this resource. If the PUT or DELETE Methods are ever defined, the wildCard property should be updated to True.
      • name: This is the name of the resource.
      • parent: The parent object. Defaults to null on creation of new resource.
      • path: Shows complete resource path to the root.
      • wildCard: A Boolean property that will allow wildcard children to the given resource. It defaults to false.
    • Methods
      • add(resourceName, wildCard): This method adds a child resource to the child property.
      • read(callback(req, res)): Handels GET requests for the resource
      • create(callback(req, res)): Handels POST requests for the resource
      • update(callback(req, res)): Hanels PUT requests for the resource
      • delete(callback(req, res)): Handles DELETE requests for the resource

##Project Specifications This project is being developed using Travis CI. Travis CI will check for style and lint errors using gulp. THe .jshintrc file and the .jscs.json file that rules those errors is availble in the root directory of the repository. Adhearing the linting rules is mandatory for a build to pass. Style rules are not currently madatory.

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago