@jimengio/serve-json

0.0.6 • Public • Published

Serve JSON

Usage

yarn global add @jimengio/serve-json
serve-json config.edn

Example of config.edn:

{
  :port 7800
  :fallback-host nil
  :routes [
    {
      :path "home"
      :get {:type :file, :file "home.json"}
    }
    {
      :path "plants/:plant-id"
      :get {:type :file, :file "plant-default.json"}
      :post {:type :file, :file "ok.json"}
      :next [
        {
          :path "overview"
          :get {:type :file, :file "overview.json"}
        }
        {
          :path "materials/:material-id"
          :get {:type :file, :file "materials.json"}
          :next [
            {
              :path "events"
              :get {:type :file, :file "events.json"}
              :delete {:code 202, :type :file, :file "ok.json"}
            }
          ]
        }
      ]
    }
  ]
}

Besides EDN, JSON, CSON, YAML and Cirru EDN are also supported(Comparison of data formats supported #5):

serve-json config.json

# also
serve-json config.cirru

# also
serve-json config.cson

# also
serve-json config.yaml

:fallback-host

When :fallback-host is specified, it will be used as a default proxy target when no config path is matched.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @jimengio/serve-json

Weekly Downloads

1

Version

0.0.6

License

MIT

Unpacked Size

207 kB

Total Files

6

Last publish

Collaborators

  • imzshh
  • jiyinyiyong
  • rebirth