Code Monkey home page Code Monkey logo

osprey-cli's Introduction

Osprey CLI

NPM version Build Status Dependency Status

The Command Line Interface (CLI) scaffolding tool to generate Osprey-based applications, ideally from a pre-defined RAML API spec, with just a single command.

Important

The current release of Osprey CLI is very much a work in progress. As it is in active use within a number of rapid development projects, it too is evolving with the needs those projects uncover. While it is proving extremely beneficial, because it's still evolving rapidly we don't yet feel it meets our criteria for a first fully stable release.

We encourage you to use it and participate by raising issues, providing feedback or contributing your own code (see below)

Coming Soon

Please check the Osprey CLI 1.0 Milestone issues list to stay up-to-date with the immediate roadmap.

Fundamentals

Osprey-CLI creates an Osprey-based application by invoking a command and specifying a few parameters. As result, you will get the skeleton of an Osprey application (coded in JavaScript or CoffeeScript) to start working right away.

Related projects

Check out the main Osprey project itself for information about the framework on which this tool generates applications.

Contributing

If you are interested in contributing some code to this project, thanks! Please submit a Contributors Agreement acknowledging that you are transferring ownership.

To discuss this project, please use its github issues or the RAML forum.

Prerequisites

To start using Osprey CLI you'll need the following:

Getting started

Install Osprey CLI globally - npm install -g osprey-cli.

Creating a new application

osprey new [raml-file or path-to-raml] [options]

For [path-to-raml-file or path-to-raml-folder] you can specify either the path to either a RAML file or a folder containing a RAML definition distributed across several files. In both cases, the original file(s) will be copied to a subfolder inside the generated project structure: [output folder]/src/assets/raml (where [output folder] is specified by the --target parameter).

Option Default Value Description
--help - Shows usage information
--version - Shows the version number
--baseUri /api Specifies base URI for your API
--language javascript Specifies output programming language: javascript, coffeescript
--target cwd Specifies output directory
--name - Specifies application name. This parameter is required.
--verbose - Sets the verbose level of output
--quiet - Silences commands
Examples

osprey new --name my-app or osprey new -n my-app

osprey new api.raml --name my-app

osprey new resources/specs -n my-app -l coffeescript

Bonus utility: Listing RAML resources in any RAML file

osprey list <raml-file>

e.g.:

osprey list api.raml

Running the API

From your terminal run: grunt (recommended: It will set up the proper listeners so changes in the code are automatically refreshed in runtime).

OR you can always run: node src/app.js

osprey-cli's People

Contributors

carlos avatar evangelina avatar fedeamdan avatar jcenturion avatar justin-calleja avatar nachoesmite avatar usarid avatar

Stargazers

 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-cli's Issues

Apikit does not validate URI parameters marked as "number"

I have this RAML:

    /pages: &pages
      type: collection
      /{pageId}:
        uriParameters:
          pageId:
            type: number
            description: The page's numeric ID
            required: true

a request to this URI http://localhost:3000/api/pages/examples returns the example, when it should have thrown a validation error, as "examples" is not a valid number

Mismatch on suggested route in scaffolded code and root prefix for route

Apikit registers itself on '/api':

apiKit.register('/api', app, {
  ramlFile: path.join(__dirname, '/assets/raml/api.raml'),
  enableConsole: true,
  enableMocks: true
});

But the route overload is not on /api:

// Adding business logic to a valid RAML Resource
// apiKit.get('/examples/:exampleId', function(req, res) {
//   res.send({ name: 'example' });
// });

Validate xml schema

Currently only json schemas are being validated. XML should be also considered

Application does not show errors if RAML is not valid

If the RAML file has a syntax or grammar error, the application does not show any error messages or helpful debugging information on startup.

API console should at least show there is an error with the RAML file.

Logged port does not match the actual listening port

When logging the startup, the logged port does not match the one used in the app (it is harcoded to 3000)

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

possible fix:

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

Add exception handle in middleware

In case of error an exception should be thrown and it should be responsibility of the exception handling middleware to return the correct response.

Why all the dev-dependencies on coffeescript on the package.json in a js scaffolded project

A newly scaffolded api has a lot of dev-dependencies that don't seem to be needed:

{
  "name": "raml-app",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "express": "3.4.4"
  },
  "devDependencies": {
    "grunt": "~0.4.2",
    "grunt-contrib-coffee": "0.7.0",
    "grunt-contrib-watch": "~0.5.3",
    "grunt-contrib-copy": "~0.4.1",
    "grunt-coffeelint": "0.0.8",
    "grunt-contrib-clean": "~0.5.0",
    "grunt-mocha-test": "~0.8.1",
    "mocha": "1.15.1",
    "should": "2.1.1",
    "supertest": "~0.8.2",
    "grunt-nodemon": "~0.1.2",
    "grunt-concurrent": "~0.4.2",
    "load-grunt-tasks": "~0.2.1",
    "grunt-wait": "~0.1.0",
    "grunt-contrib-jshint": "~0.8.0"
  }
}

Routing weirdness

I have this RAML:

    /pages:
      type: collection
      /{pageId}:

with this setup:

apiKit.register('/api', app, {
  ramlFile: path.join(__dirname, '/assets/raml/api.raml'),
  enableConsole: true,
  enableMocks: true
});

I expect a GET /localhost:3000/pages/api to 404, but it returns the sample for /pages/api

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.