GithubHelp home page GithubHelp logo

isabella232 / frock-static Goto Github PK

View Code? Open in Web Editor NEW

This project forked from urbanairship/frock-static

0.0 0.0 0.0 56 KB

A static file server for frock

Home Page: https://www.npmjs.com/package/frock-static

License: Other

JavaScript 100.00%

frock-static's Introduction

frock-static

A static file server plugin for frock, that can source its static files from interesting places.

Build Status npm install js-standard-style

A static file source can be:

  • A remote URL
  • A local directory of files
  • A single file

It's important to note that this is not a proxy; it doesn't pass any information about your request to the data source, nor does it modify the sourced data in any way.

frockfile Example

In your working directory, create a frockfile.js:

{
  "servers": [
    {
      "port": 8080,
      "routes": [
        {
          "path": "/api/people",
          "methods": ["GET"],
          "handler": "frock-static",
          "options": {
            "file": "fixtures/static/people.json",
            "contentType": "application/json"
          }
        },
        {
          "path": "/api/remote",
          "methods": ["GET"],
          "handler": "frock-static",
          "options": {
            "status": 201,
            "url": "http://paste.prod.urbanairship.com/raw/6255",
            "contentType": "application/json"
          }
        },
        {
          "path": "/api/static/*",
          "methods": ["GET"],
          "handler": "frock-static",
          "options": {
            "dir": "fixtures/static/",
            "baseUrl": "/api/static/"
          }
        }
      ]
    }
  ]
}

frock-static also supports a shorthand syntax, which is convenient for when you have to define a bunch of static sub-routes:

{
  "servers": [
    {
      "port": 6070,
      "routes": [
        {
          "path": "/api/resources/*",
          "methods": ["GET"],
          "handler": "frock-static",
          "options": {
            "routes": [
              {
                "path": "people",
                "file": "fixtures/static/people.json"
              },
              {
                "path": "places",
                "file": "fixtures/static/places.json"
              },
              {
                "path": "things",
                "url": "https://raw.github.com/someone/something/file.json"
              }
            ],
            "contentType": "application/json"
          }
        }
      ]
    }
  ]
}

License

Apache 2.0, see LICENSE for details.

frock-static's People

Contributors

fardog 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.