Coder Social home page Coder Social logo

osprey's People

Contributors

blakeembrey avatar brevity avatar carlos avatar cmd-johnson avatar danielwpz avatar der-on avatar dploeger avatar forsakenharmony avatar greenkeeper[bot] avatar greenkeeperio-bot avatar jcenturion avatar jmesters avatar jstoiko avatar lucasfo avatar muka avatar nachoesmite avatar postatum avatar sichvoge avatar smulesoft avatar usarid 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  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

osprey's Issues

Strict Mode

  • Turn off mocks for production
  • Turn off debug logging for production
  • Warn about not overwritten resources
  • Block unknown routes using 404

API Console broken when using !include

When using !include (relative paths, included files are in the same folder as the RAML-file), the API Console gets the paths wrong, displaying:

{"context":"while fetching /user.schema.json", [...],
 "message":"cannot fetch /user.schema.json (Not Found)" [...]

This has been working until this commit. So if I add the trailing slash in line 14 in dist/assets/console/index.html back, so that it says

    <raml-console src="apiPath/" with-root-documentation></raml-console>

then the console is working again.

To reproduce you can setup a minimal project using osprey-cli utilizing any RAML-file containing an !include directive with a relative path, like e.g.

schemas:
 - user: !include user.schema.json

Would adding the slash back break anything?

Not possible to install

Not possible to install via npm install osprey -g (Linux Mint 16 Petra)

../vendor/libxml/xpath.c: In function ‘xmlXPathNodeCollectAndTest’:
../vendor/libxml/xpath.c:12401:28: warning: comparison between ‘xmlElementType’ and ‘xmlXPathTypeVal’ [-Wenum-compare]
       } else if (cur->type == type) {
                            ^
../vendor/libxml/xpath.c:12402:13: warning: comparison between ‘xmlXPathTypeVal’ and ‘enum <anonymous>’ [-Wenum-compare]
    if (type == XML_NAMESPACE_DECL)
             ^
In file included from ../vendor/libxml/xpath.c:185:0:
../vendor/libxml/xpath.c: At top level:
../vendor/libxml/trionan.c:218:1: warning: ‘trio_is_negative’ defined but not used [-Wunused-function]
 trio_is_negative
 ^
  CC(target) Release/obj.target/libxml/vendor/libxml/xpointer.o
../vendor/libxml/xpointer.c: In function ‘xmlXPtrNewRangeNodePoint’:
../vendor/libxml/xpointer.c:451:21: warning: comparison between ‘xmlElementType’ and ‘enum <anonymous>’ [-Wenum-compare]
     if (start->type != XPATH_POINT)
                     ^
  AR(target) Release/obj.target/vendor/libxml/xml.a
  COPY Release/xml.a
  CXX(target) Release/obj.target/xmljs/src/libxmljs.o
make: g++: Command not found
make: *** [Release/obj.target/xmljs/src/libxmljs.o] Error 127
make: Leaving directory `/home/xxx/dev/osprey/node_modules/osprey-resources/node_modules/osprey-method-handler/node_modules/libxmljs/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.11.0-12-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/xxx/dev/osprey/node_modules/osprey-resources/node_modules/osprey-method-handler/node_modules/libxmljs
gyp ERR! node -v v0.10.15
gyp ERR! node-gyp -v v0.10.9
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/xxx/dev/osprey/npm-debug.log
npm ERR! not ok code 0

Can't use console with other middleware

Registering the console triggers express to mount the router middleware, which is occurring before any Osprey middleware is registered since it's async. The best fix for this would be to make Osprey mount "placeholder" middlewares that don't do anything until the async raml is loaded.

Osprey hiding app exceptions

If I throw an exception* (ie: call null.a.b) in a method of one of my controllers that gets called on a route defined inside osprey api wrapper, that exception isn't shown on the terminal and a 404 response is returned to the client.

One probable cause is that exception are not re-thrown inside .catch handler on osprey promise chain.

Check responses for development

This will warn through logging if the response is correct. Example: if a response header is ok based on RAML or if all the required headers are being send on response.

Nested URI parameter validation

Osprey does not provide validation for nested resources that have URI validation. For example, the below resource will validate apiVersionId if the path is /abc/123, while apiId will only validate when the path is /123.

/{apiId}:
  uriParameters:
    apiId:
      type: integer
      minimum: 1

  /{apiVersionId}:
    uriParameters:
      apiVersionId:
        type: integer
        minimum: 1

Console doesn't load

Trying to load console with the project generated from example league.raml, I see the following content from http://localhost:3000/api/console:
{"context":"while fetching /api/","context_mark":null,"message":"cannot fetch /api/ (while fetching /api/\ncannot fetch /api/ (NetworkError: A network error occurred.), check that the server is up and that CORS is enabled)","problem_mark":null}

From the command line I see the following output:
local:~/sites/raml-workshop/osprey_test/leagues-app (master)$ node src/app.js
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Osprey: Osprey::APIConsole has been initialized successfully listening at /api/console
listening on port 3000
GET /api/console 200 19ms - 605b
GET /api/console/styles/app.css 304 9ms
GET /api/console/scripts/vendor.js 304 9ms
GET /api/console/scripts/app.js 304 6ms

/home/gimballock/sites/raml-workshop/osprey_test/leagues-app/node_modules/osprey/dist/osprey.js:78
data = data.toString().replace(/^baseUri:.*$/gmi, "baseUri: " + ap
^
TypeError: Cannot call method 'toString' of undefined
at /home/gimballock/sites/raml-workshop/osprey_test/leagues-app/node_modules/osprey/dist/osprey.js:78:25
at fs.js:207:20
at Object.oncomplete (fs.js:107:15)

Mock data module roadmap?

Hi!

I was wondering if there was some code somewhere I could hack on with the beginnings of the mock data cli module for osprey 0.2.0-alpha.

I'm starting to use that app I have and could REALLY REALLY use the ability to serve the example json responses as mock data based on the baseUrl and defined routes in the raml.

If there isn't anything hacked out yet, any pointers would be most helpful.

Thanks for all of your help. I'll try not to be too impatient. :)

osprey.create should take a done callback

it appears osprey.create does some async stuff and so a caller should be able to pass a done function and be called when this async process completes -- i.e. setting up routes, etc. without the callback, we have to put waits in our code

raml file does not have baseUri replaced in it

the baseUri property of the raml file should be updated with the servers actual full path (protocol, host, [port,] path).

This does not happen at all for the raml served at //api.raml.
The incorrect url is substituted for the raml served at / (It always puts http://localhost:3000/). The protocol and port are ignored and probably the host as well.

Not overwriting resources when osprey gets created multiple times

Running my integration tests involves having to initialize osprey multiple times, but it fails to overwrite the resources on subsequent test runs (I’m not seeing the ‘RAML successfully loaded’ message and the ‘Overwritten resource’ messages anymore after the first test). This causes the tests to fail since supertest start getting mocked results. It looks like the file is being cached based on the code, so is there a way to turn off the cache or have osprey overwrite the endpoints every time?

Raml file is served with incorrect content type

Osprey serves the raml file with
Content-type: application/octet-stream
this causes the file to be downloaded instead of being viewed in the browser.

How about using the following?
Content-type: text/yaml

Should generate an express app

If I were using osprey, I would expect that it would create a express application which I could then use however I see fit. This means I could mount it to my normal application or use it as the base of the application. There are also a lot of benefits to this approach:

  • Osprey applications will be self contained and don't affect parts of the users application
  • The osprey app can be mounted any number of times on any number of routes
  • You don't need to impose parsing logic onto the users application which can actually cause security concerns
  • You can use the xml middleware in osprey without forcing it onto users (same with form encoding, json, etc.)

Basic usage:

app.use('/api', osprey.create({
  ramlFile: path.join(__dirname, '/assets/raml/api.raml')
}));

Example:

var api = osprey.create({
  ramlFile: path.join(__dirname, '/assets/raml/api.raml')
});

api.get('/resource', function(req, res) {
  //// Your business logic here!
});

app.use('/api', api);

osprey does not work with express 4

Given the following code which integrate osprey with express4. It returns Cannot GET /api/xxx for every path.

var express = require('express');
var path = require('path');
var osprey = require('osprey');

var app = module.exports = express();

app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.compress());
app.use(express.logger('dev'));

app.set('port', process.env.PORT || 3000);

api = osprey.create('/1', app, {
  ramlFile: path.join(__dirname, 'api.raml'),
  enableValidations: false,
  logLevel: 'debug'  //  logLevel: off->No logs | info->Show Osprey modules initializations | debug->Show all
});

if (!module.parent) {
  var port = app.get('port');
  app.listen(port);
  console.log('listening on port ' + port);
}

API returns 404 for everything

It doesn't matter what I do, trying any of the API calls returns 404 and even calling the api directly from the browser returns 404. I even tried your example on github and it return 404 as well... any ideas?

Allow using middlewares when defining a new api.

I need to define authenticated apis using passport authentication method and a custom object that handle permissions.

If I define this api example against express app, it work as well. But with the object that osprey.create returns, it always gives me 404:

var api = osprey.create('/api', app, {
  ramlFile: path.join(__dirname, '../raml_spec/api_spec.raml'),
  logLevel: app.get('env') !== 'test' ? 'debug' : 'off'
});

api.describe(function (api) {
  api.put(
    '/templates/:id',
    accountController.ensureAuthenticated, 
    permissions.can('edit'),                           
    templatesController.edit);                     
})
.then(function() {
  app.listen(app.get('port'), function() {
    debug('Express server listening on port ' + server.address().port);
  });
})

Thanks!

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.