{"id":16182428,"url":"https://github.com/drawveloper/connect-tryfiles","last_synced_at":"2025-03-19T02:30:38.687Z","repository":{"id":16590765,"uuid":"19345120","full_name":"drawveloper/connect-tryfiles","owner":"drawveloper","description":"nginx try_files style connect middleware: serve local file if exists or proxy to address","archived":false,"fork":false,"pushed_at":"2015-04-04T13:34:09.000Z","size":195,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T14:05:43.460Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drawveloper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-01T13:27:00.000Z","updated_at":"2021-04-07T08:23:42.000Z","dependencies_parsed_at":"2022-09-26T20:52:33.224Z","dependency_job_id":null,"html_url":"https://github.com/drawveloper/connect-tryfiles","commit_stats":null,"previous_names":["gadr/connect-tryfiles","drawveloper/connect-tryfiles"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawveloper%2Fconnect-tryfiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawveloper%2Fconnect-tryfiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawveloper%2Fconnect-tryfiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drawveloper%2Fconnect-tryfiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drawveloper","download_url":"https://codeload.github.com/drawveloper/connect-tryfiles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960361,"owners_count":20375101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T06:31:39.130Z","updated_at":"2025-03-19T02:30:38.340Z","avatar_url":"https://github.com/drawveloper.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"connect-tryfiles\n================\n\n# WARNING: DEPRECATED\n\nThis was a nice experiment, but right now there is a better way to accomplish the same.\n\nAs the new `serve-static` middleware from Express now calls `next` when it doesn't find a file, you can simply add a proxy afterwards:\n\n    connect = require 'connect'\n    http = require 'http'\n    url = require 'url'\n    serveStatic = require 'serve-static'\n    proxy = require 'proxy-middleware'\n\n    app = connect()\n        .use(serveStatic('./files'))\n        .use(proxy(url.parse('https://example.com/endpoint')))\n\n    server = http.createServer(app).listen(8000)\n\nHere be dragons! You have been warned :)\n\n### Description\n\n![Build status](https://travis-ci.org/firstdoit/connect-tryfiles.png)\n\nnginx try_files style connect middleware: serve local file if exists or proxy to address\n\n### Idea\n\nIf a local file is available at the path corresponding to the URL, this middleware will do nothing (giving the chance to some other middleware serve it).\nElse, it will proxy the request to the given target.\nThis way, you can serve local files easily and proxy the rest to your remote server.\n\n### Usage\n\n    connect = require 'connect'\n    http = require 'http'\n    tryfiles = require 'connect-tryfiles'\n\n    app = connect()\n        .use(tryfiles('**', 'http://localhost:9000', {cwd: 'files'}))\n        .use(connect.static('./files'))\n\n    server = http.createServer(app).listen(8000)\n\nAssuming there is\n\n- a file at `./files/foo`\n- a different server listening at localhost:9000 that returns \"world\" to any request\n\nRequests to:\n\n- `http://localhost:8000/foo` will retrieve the file at `files/foo`\n- `http://localhost:8000/hello` will return \"world\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrawveloper%2Fconnect-tryfiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrawveloper%2Fconnect-tryfiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrawveloper%2Fconnect-tryfiles/lists"}