Code Monkey home page Code Monkey logo

play2-stub's Introduction

Collaborate with front-end developers with no bottle necks!

play2-stub is a play framework plugin for implementing server stub without any boilerplate coding. With

routes

GET    /index   contollers.YourController.index
...
GET    /*file   jp.co.bizreach.play2stub.StubController.at(file)

application.conf

play2stub {
  routes: [
    {
      "GET /author/~authorName/books" {
        template = "author-biology"
        data = "authors/:authorName.json"
      }
    }
  ]
}

Currently, play2-stub only suppoorts Handlebars templates and depends on play2-handlebars .

Motivation

Sometimes engineers collaborate with front-end engineers or UX designers in one play application. While engineers are implementing eagerly, they want server responses to test their artifacts. Today since clients become richer and richer, they really needs clear responses for both html and ajax response.

UX/UI designers/engineers also want data variation as we engineers do, to test client-side validation behaviors, for layout adjustment and so on.

Features

  • Handlebars(currently) template
  • Dynamic parameter passing
  • Implicit routing

Getting Started

  1. Add a dependency in Build.scala or build.sbt

    "jp.co.bizreach" %% "play2-stub" % "0.1.0"

or

"jp.co.bizreach" %% "play2-stub" % "0.2-SNAPSHOT"

with the below to refer the Maven's snapshot reository. resolvers += "Maven Central Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

  1. Add a line in conf/play.plugins. Usually, you also need to add Handlebars plugin declaration.

    1000:jp.co.bizreach.play2handlebars.HandlebarsPlugin 2000:jp.co.bizreach.play2stub.StubPlugin

  2. Add mappings to StubController routes in routes. Each http method needs a line.

    GET /*file jp.co.bizreach.play2stub.StubController.at(file)

  3. Add routes in application.conf. The grammar is quite similar to that of Play's route. But instead of ":", use "~" for path parameters.

    play2stub { routes: [ { "GET /author/~authorName/books" { template = "author-biology" data = "authors/:authorName.json" } } ] }

  4. Then put template files or/and json files and run your application.

  5. See src/test/play2-sample1-stub for more routing samples.

Roadmap

0.2 #1 add common headers and cookie values using filter #2 enable no returning value #3

0.3 and beyond

  • Some kind of collaboration with REST documentation frameworks such as Blueprint and RAML

play2-stub's People

Contributors

scova0731 avatar

Watchers

 avatar

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.