Code Monkey home page Code Monkey logo

http-framework's Introduction

http-framework

A web framework based purely on require('http')

Table of Contents generated with DocToc

Motivation

require('http') is a web framework. All you need are a few small modules that do one thing well when you are building your web application route handlers.

This module aggregates and documents (with examples) a selection of small modules that can be used to achieve this goal.

It's recommended you check out the:

I do not recommend you use this "framework". You should check out the small modules and use them directly. Use the list of examples here for inspiration.

http-framework is an OPEN Open Source Project, see the Contributing section to find out what this means.

Check out the modules folder for an example of small modules you can combine to build your own custom "framework"

See the package.json dependencies hash for an example of many small modules used in the examples folder of this project.

For a complete list of Modules check out the wiki

For a tutorial / workshop see http-works

module docs

rest of the modules

// TODO

For now see the examples folder

express inspired examples

These examples are clones of express examples demonstrating how to author web apps without frameworks.

  • auth An example demonstrating how to login and authenticate users
  • auth-helpers An example demonstrating how you can restrict certain routes in your apps to only be accessed by certain types of users
  • content-negotiation An example demonstrating how you can return different types of content based on what the user asks for in his Accept header.
  • cookie-sessions An example of storing session information in a users cookie
  • cookies An example of setting a cookie to track a user
  • cors An example of adding cors support to your HTTP server
  • downloads An example of allowing users to download files from your server
  • error An example of handling errors in your HTTP server
  • error-pages An example of rendering custom 500 and 404 pages in your web server
  • expose-data-to-client An example of putting server side state into your template so that it can be accessed from browser javascript
  • hello-world A simple hello world example
  • multipart An example demonstrating file uploads and saving them to disk temporarily.
  • mvc An over engineered example of how to structure a slightly larger web application. Includes configuration, modularity and databases. Take ideas from it, please do not copy paste it
  • online An example of using redis and the online module to track user presence
  • route-map An example of a map utility function that can be used to structure your routes differently. This demonstrates you can do whatever you want, if you like it, do it.
  • route-seperation An example of spreading your route handlers over multiple files.
  • search An example of doing a database query over XHR with a web server backed by redis
  • session An example of storing information in a session. The session is either backed by redis or memory.
  • static-files An example of serving static files for your web server
  • vhost An example of handling multiple sub domains as seperate applications in a singlue web server
  • web-service An example JSON REST api web server. Contains API key authentication and error handling

Credit for the applications goes to

  • @tj & express maintainers

hapi inspired examples

These examples are clones of hapi examples demonstrating how to author web apps without frameworks.

  • tail An example of handling async errors in your applications after you have ended the HTTP response
  • validate-api An example of how to add validation logic to your HTTP route handlers. Both validating query params & the HTTP body

Credit for the application's goes to

  • @hapijs & hapi maintainers

connect inspired examples

These examples are clones of connect examples demonstrating how to author web apps without frameworks.

  • basic-auth An example of handling basic authorization style authentication of a web server.
  • csrf An example of adding csrf security to a form in a web application

Credit for the applications goes to

  • @tj & connect maintainers

Todo

  • Finish porting express examples
  • continue porting hapi examples
  • continue connect examples
  • Port koajs examples
  • Port restify examples
  • Port partial.js examples
  • Finish documentation
  • Get community feedback
  • Author new fresh examples

Installation

npm install http-framework

Contributors

  • Raynos
  • Matt-Esch
  • maxogden

MIT Licenced

http-framework's People

Contributors

aredridel avatar faiq avatar internetsadboy avatar matt-esch avatar max-mapper avatar raynos avatar seanewest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

http-framework's Issues

support multiple templates

People like frameworks because they support many templating languages

We should have a examples-template folder with at least 5 different templating languages for the same web server showing that plug & play just works.

Multipart-form example needs improving/supplementing

I just want to keep track of some of the offline discussions surrounding multipart forms.

The example currently naively writes all files to disk which can be achieved more simply by adding a listener to the "file" event, and configuring the upload directory.

Personally I think writing to disk has its use cases, but you do need to be aware of the attack vectors associated with this. File uploads should be removed after the request is handled, or moved to a permanent store. Temporary file directories should not allow code to be executed in them or have files publicly accessible to any web server. It is also a good idea to write a service to periodically clean old files in case anything is left behind.

An example based on streaming files to a 3rd party file store also has its benefits since this is a popular solution as well. It removes the developer from the complexity of managing the server infrastructure.

I think we ought to cover both use cases.

Case 1: User wants to store files on the server itself in some resource directory. This should use a simple file storage approach, highlighting the security precautions required to make this safe.

Case 2: We want the data to pass through to a third party service in a streaming fashion. This should preferably be an amazon s3 example that doesn't touch the disk.

Parsing received data

Granted I want to use simple middleware to parse arguments submitted to the server.
Shall I use multipart example, or there is no appropriate example yet?

add auth example using oauth(1|1A|2)

confusion about how to set up "sign in with google" would be handy. this common (but a bit more complex) task can be one that scares users off from the small modules approach.

demonstrate everything

@thlorenz says

so I think the main point to show is that you can make it do EVERYTHING by using other modules

Basically for this to have value over frameworks we need to demonstrate how it can handle all the things.

Serving up templates

Might be interesting to see any example of serving up template files using a popular templating engine (hogan, jade, ejs, etc...) and not just .js template files.

Do the examples use too many modules?

If we take a look at the csrf example you will see it uses a lot of dependencies.

When compared to isaacs/csrf-lite or connect csrf example you can see that those examples are very light in terms of dependencies and the csrf example in the examples folder has a lot of dependencies

  • connect, 2 dependencies
  • csrf-lite, 3 dependencies
  • http-framework/csrf, 9 dependencies

cc @substack @thlorenz . Is it just me or should examples use less modules?

feedback on mvc example

I did a large mvc example

I want it to demonstrate a way of structuring applications that's not stupid but also not too opinionated / bullshit.

It would be good to get some eyes on it.

@Matt-Esch you had some opinions about structuring applications as standalone feature folders. I tried to structure it like that, would love to hear about the good & bad.

@thlorenz you had some opinions about structuring larger apps as modules. I tried to structure it like that, would to love to hear about the good & bad

There should be some more indepth tutorials.

The immediate example that comes to mind (as a previous python/django dev) is the django docs tutorial: https://docs.djangoproject.com/en/dev/intro/tutorial01/

In the case of http-framework, this comes down to creating a couple simple sites. Ideas that come to mind are:

  • A site that has a login and some user specific settings
  • An API server, especially one with auth tokens or the like

Some things that are bike shed-y and I'd like to get a top down answer.

  • Any tech that should be banned from us in tutorials (specific DBs, libs, etc).
  • Whether the plan would be to render the markdown into html for something like GH pages or just have a directory full of markdown.
    • If it is rendered, what tool do you want used (to so any authors can make sure it works)
    • Would there be anyone who wants to do design work and make it actually look nice

default templates

In the examples we use hyperscript for a default templating language.

This choice was made because it's the simplest thing that works I could think of. one dependency. template re-use with functions & template inheritance with require.

Maybe there is a simpler string / text file alternative ?

cc @dominictarr

Modules wiki backlog

Leave a comment on this issue with suggested modules to add to the wiki in case you dont know what category they are in or how to describe them

  • doorknob
  • persona-id
  • auth-socket
  • hyperglue
  • connections
  • basic

Demonstrate `error-page`

@isaacs has an error-page module.

I should probably write an alternative error-pages example demonstrating usage of it.

@isaacs do you have any suggestions for an idiomatic example ? Maybe it's easier if you add an example to the error-page module and I just put some links to it.

security

Each one of the modules that I list in the package.json really should be security audited.

I recently fixed an outstanding buffer overflow attack vector in body

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.