Coder Social home page Coder Social logo

lout's People

Contributors

adityabakle avatar adrieankhisbe avatar adrivanhoudt avatar arb avatar baer avatar chaseadamsio avatar christianmurphy avatar cjnqt avatar danieladams456 avatar deepflame avatar geek avatar hueniverse avatar joeybaker avatar johnbrett avatar klokoy avatar kpdecker avatar krisb avatar lloydbenson avatar mac- avatar mani95lisa avatar marsup avatar mathieuloutre avatar mcandre avatar nargonath avatar nlf avatar oayandosu avatar phated avatar richardlitt avatar thegoleffect 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lout's Issues

Breaking Build

Something changed in one of the Hapi dependencies (Vision I think) that is breaking the build now.

Node 0.10

Lout's package still requires an old version of Hapi and a conflicting (with new Hapi) version of node.

TypeError: Object.keys called on non-object

Error at Line 144 function internals.getParamsData
param.children is null if data type is object and have no children.

var childrenKeys = Object.keys(param.children);

so it's should be
if(param.children) {
....
}

handlebars dependency missing

This plugin fails to load do to a missing handlebars dependency when installing from npm. Handlebars is listed only as a dev dependency.

Question about allowedValues

I'm noticing that the allowedValues that are available to the template in the different route params seem to just contain an array of 1 item that appears to be a stringified Array of the allowed values.

My question is, is this intended behavior?

For example, if I have config for a route that looks like this:

{
    path: '/foo/{id}',
    method: 'POST',
    config: {
        handler: function(request, reply) { reply({some:'data'}); },
        validate: {
            payload: {
                id: Hapi.types.String().allow(['one','two','three']).required()
            }
        }
    }
}

Then the allowedValues property of payloadParams on the route object in the template returns this value:

["[ \"one\", \"two\", \"three\" ]"]

instead of:

['one','two','three']

So ultimately, I can't easily loop through each value.

If this was not intentional, I can submit a fix. Thanks!

Output to static files?

We'd be interested in using lout to generate our docs, but don't want an additional dynamic route enabled.

Can't get auth option to work

Our implementation use a custom authentication plugin. Our server.pack method looks something like this currently:

    server.pack.require
        "hapi-auth-custom": hapiAuthCustomOpts 
        "lout": loutOps,
        (err) ->

            server.auth.strategy "custom", "custom", validateUser

            # ... routes, etc...

If I set the auth option for lout {auth: "custom"}, it complains:

Error: Unknown authentication strategy: custom

What am I doing wrong :)

Number min/max is not documented

version

"lout" : "^6.0.1"

config

server.route({
    method: 'POST', path: '/test',
    config: {
      validate : {
        payload: {
          page : Joi.number().min(1).max(99999).required()
        }
      },
      handler: function(req, resp) {
        resp('test');
      }
    }
});

result in /docs

page 

Type

number
Forbidden Values
Infinity
-Infinity

No mentioning of .min(1).max(99999)

Upgrade to Joi 5.1.0

Alternatives are now described as objects.
Date.min/max can now take references.

Exclude certain methods

I know that I can disable a specific route but I'd would be nice if I could tell lout to ignore a certain method entirely.

The reason for me is that we use "*" to handle all the 400 properly but obviously I don't want them to show up in the docs.

What do you guys think?

Payload params shows for GET routes

Lout by default shows "Type any" for Path, Query and Payload parameters by default, but Hapi doesn't accept a payload for a GET request. Is it possible to remove this? I tried:

validate: {
     payload: false
}

On a route, but Hapi will return a "Cannot Validate" error since it's a GET. If there's nothing I can do config wise to fix this, should I submit a PR to disable the section from being generated for GETs by default?

I think it would be handy if we had a way disable this from being generated for POST, and other methods as well...

Testing Updates

  • Migrate to lab 5.x.x
  • Migrate to code 1.x.x
  • Add -a code to makefile

Project maintainer

We are looking for someone to take over the project and maintain it moving forward. Our team isn't currently using this which makes it hard to support.

joi 4.0

Not yet in hapi (coming in 5.0) but should start looking at the changes in how describe work and all the new features.

Style config.description?

Is there any way to style the output of the route description, for instance using a custom markup language? Displaying inline JSON is ugly and will be unreadable for big objects:
image

My use case is pretty simple: I want to display the route description (using text) and a sample return value, which I'd like to embed in a <pre> tag. At the moment all HTML tags are escaped, am I missing something?

How do I exclude a route?

I am loving using lout with Hapi 6.x but I need to exclude some routes from the index.
How do I do that?

I tried this route to exclude for example with a plugins: lout:false

        {
            method: 'GET',
            path: '/{path*}',
            handler: {
                directory: { path: './public', listing: false, index: true }
            },
            plugins: {
                lout: false
            }
        }

but it complains with

Error: Invalid route options (/{path*}) {
  "method": "GET",
  "path": "/{path*}",
  "handler": {
    "directory": {
      "path": "./public",
      "listing": false,
      "index": true
    }
  },
  "plugins" [1]: {
    "lout": false
  }
}

What do I need to do to exclude a route?

TypeError: Cannot read property 'key' of undefined

Hi guys,

I am new to hapi and lout. So it can well be that I did something wrong.

Having these packages:

    "hapi": "^4.1.4",
    "hoek": "^2.1.0",
    "joi": "^4.2.0",
    "lout": "^3.1.2"

and the following server code:

var Hapi = require('hapi');
var server = Hapi.createServer('0.0.0.0', parseInt(process.env.PORT, 10) || 3000);

server.route({
    method: 'GET',
    path: '/hello',
    handler: function(req, reply) {
        reply('i am a beautiful butterfly');
    }
});

server.pack.require('lout', function() {
    server.start(function () {
        console.log('Server started at: ' + server.info.uri);
    });
});

I get:

Server started at: http://0.0.0.0:3000
Debug: hapi, internal, implementation, error 
    TypeError: Cannot read property 'key' of undefined
    at Object.exports.process (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/joi/lib/errors.js:54:81)
    at internals.Any.validate (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/joi/lib/any.js:527:19)
    at internals.Any.validateCallback (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/joi/lib/any.js:533:20)
    at Object.internals.input (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/lib/validation.js:101:19)
    at exports.query (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/lib/validation.js:17:22)
    at /Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/lib/request.js:314:13
    at iterate (/Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/async/lib/async.js:149:13)
    at /Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/async/lib/async.js:160:25
    at /Users/aboehrnsen/Developer/code-wemo/songbox/node_modules/hapi/node_modules/hoek/lib/index.js:467:22
    at process._tickDomainCallback (node.js:459:13)

Any ideas?

Add simple way to provide custom CSS

Instead of setting own basePath to custom templates it would be great to just point to own CSS files, as this is probably the most common reason for customisation.

Prepare for hapi v6.0

hapijs/hapi#1664

Quick review shows that moving plugin.loader(), requiring handlebars directly, and moving to absolute path to the templates directory will allow it to be backwards compatible change.

Setting lout endpoint config to '/' causes exception

Configuring lout with an endpoint of / causes the following exception:

/code/node_modules/hapi/node_modules/hoek/lib/index.js:394
    throw new Error(msgs.join(' ') || 'Unknown error');
          ^
Error: Invalid path: //css/{path*}
    at Object.exports.assert (/code/node_modules/hapi/node_modules/hoek/lib/index.js:394:11)
    at new module.exports.internals.Route (/code/node_modules/hapi/lib/route.js:27:11)
    at /code/node_modules/hapi/lib/router.js:110:25
    at Array.forEach (native)
    at /code/node_modules/hapi/lib/router.js:107:17
    at Array.forEach (native)
    at internals.Router.add (/code/node_modules/hapi/lib/router.js:104:13)
    at internals.Server._route (/code/node_modules/hapi/lib/server.js:425:18)
    at internals.Pack._applySync (/code/node_modules/hapi/lib/pack.js:593:14)
    at Object.methods.route (/code/node_modules/hapi/lib/pack.js:198:22)

Unable to handle Array with max items constraint

Lout will crash when it encounters a param which is of type array and has a rule which describes the max number of items.

Below is an example param which would cause lout to crash.

{ type: 'array',
  flags: { insensitive: false, allowOnly: false },
  description: 'Some Attribute',
  valids: [ undefined ],
  invalids: [ null ],
  rules: [ { name: 'max', arg: 5 } ] }

The crash is caused by the following lines starting at 196 of lib/index.js

        param.rules.forEach(function (rule) {

            data.rules[rule.name] = rule.arg.map(function (type) {

                return internals.getParamsData(type.describe());
            });
        });

Add support for auth.scope to route templates

Currently generated documentation for routes includes auth strategy, but not scope. For our use cause being able to document scope for other developers would be extremely helpful. With the way we implement scope, this would essentially would tell them which methods they have permissions to use (we plan on having quite a few different scopes with varying access to routes).

I can do a fork, but I thought I would ask first before sending you a pull request - maybe there is a reason you don't want scope exposed?

Authentification default

I just tried lout quickly with my current server under the latest hapi with a defaultMode for authentication. Unsurprisingly, I got a "missing authentication" error. Maybe an option can be added to specify the authentication mode on the documentation route?

basePath doesn't seem implemented

Hi...

README.md indicates 'basePath' is available (to change the template directory)....but couldn't see this implemented. (Perhaps I've missed something.)

I needed to add:

var internals = {
defaults: {
basePath: './templates'
}
}

and reference this in register:

plugin.views({ engines: { html: 'handlebars' }, path: settings.basePath });

Instead of this:

plugin.views({ engines: { html: 'handlebars' }, path: './templates' });

thanks

Display sample request/response

If an endpoint has a payload validation schema then we can generate a sample request payload to display (Instead of adding mock data, it could be { "item": "string", "item2": 100 }

If the endpoint also has response validation then we can also provide a sample response 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.