{"id":18368135,"url":"https://github.com/thinkjs/think-resource","last_synced_at":"2025-07-30T17:03:34.677Z","repository":{"id":65374738,"uuid":"87779428","full_name":"thinkjs/think-resource","owner":"thinkjs","description":"Resource for ThinkJS 3.x","archived":false,"fork":false,"pushed_at":"2017-07-30T05:37:54.000Z","size":26,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-06-26T11:18:06.822Z","etag":null,"topics":["middleware","resource-manager","static","thinkjs3"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/thinkjs.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":"2017-04-10T07:21:21.000Z","updated_at":"2021-11-04T05:30:13.000Z","dependencies_parsed_at":"2023-01-20T01:25:21.508Z","dependency_job_id":null,"html_url":"https://github.com/thinkjs/think-resource","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thinkjs/think-resource","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-resource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-resource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-resource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-resource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinkjs","download_url":"https://codeload.github.com/thinkjs/think-resource/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-resource/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267409067,"owners_count":24082563,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["middleware","resource-manager","static","thinkjs3"],"created_at":"2024-11-05T23:24:45.718Z","updated_at":"2025-07-30T17:03:34.623Z","avatar_url":"https://github.com/thinkjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# think-resource\nResource for ThinkJS 3.x\n\n[![npm](https://img.shields.io/npm/v/think-resource.svg)](https://www.npmjs.com/package/think-resource)\n[![Build Status](https://travis-ci.org/thinkjs/think-resource.svg?branch=master)](https://travis-ci.org/thinkjs/think-resource)\n[![Coverage Status](https://coveralls.io/repos/github/thinkjs/think-resource/badge.svg?branch=master)](https://coveralls.io/github/thinkjs/think-resource?branch=master)\n\nthink-resource is an static-file handler for ThinkJS 3.x. \n\n## Installation\n\n```\n$  npm install think-resource\n```\n\n## \n\n## API\n\nModify `src/config/middleware.js`\n\n```js\nconst resource = require('think-resource')\n\nmodule.exports = [\n  { \n      handle: resource,\n      options: {\n           root: '.',\n           publicPath: '/static',\n           index: 'index.html',\n           hidden: false,\n           format: true,\n           gzip: false,\n           extensions: ['.txt'],\n           maxage: 0,\n           setHeaders: function(res, path, stats) {\n              ...\n           },\n           notFoundNext: false\n      }\n  }\n]\n```\n\n### Options\n\n- `root`:  Root directory to restrict file access， `require`.\n- `index`: Default file name, default is `index.html`.\n- `hidden`: Allow transfer of hidden files. default is `false`.\n- `format`:  If not false (defaults to true), format the path to serve static file servers and not require a trailing slash for directories, so that you can do both /directory and /directory/, default is `false`.\n- `gzip`: Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. default is `false`.\n- `extensions`: Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. default is `false`.\n- `maxage`: Function to set custom headers on response. Browser cache max-age in milliseconds, default is `0`.\n- `publicPath`: Public path for route-match. default is `/`.\n- `setHeaders`: Function to set custom headers on response. default is `false`. usage: `setHeaders: function(res, path, stats){}`\n- `notFoundNext`: If it can't find target file, will continue excuting `next` function.  default is `false`.\n\n## Contributing\n\nContributions welcome!\n\n## License\n\n[Mit](https://github.com/thinkjs/think-resource/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkjs%2Fthink-resource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkjs%2Fthink-resource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkjs%2Fthink-resource/lists"}