{"id":16625814,"url":"https://github.com/cushJS/cush-cdn","last_synced_at":"2025-05-11T04:30:39.076Z","repository":{"id":45254628,"uuid":"139283422","full_name":"aleclarson/cush-cdn","owner":"aleclarson","description":"Local asset server for cush","archived":false,"fork":false,"pushed_at":"2024-11-08T05:44:32.000Z","size":28,"stargazers_count":0,"open_issues_count":17,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-08T06:29:19.261Z","etag":null,"topics":["assets","cush","development","server"],"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/aleclarson.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-30T22:08:48.000Z","updated_at":"2018-07-01T14:55:01.000Z","dependencies_parsed_at":"2024-03-22T22:28:50.079Z","dependency_job_id":"6e0aa630-0397-4c95-ae44-08f6f2a2c4b7","html_url":"https://github.com/aleclarson/cush-cdn","commit_stats":{"total_commits":14,"total_committers":1,"mean_commits":14.0,"dds":0.0,"last_synced_commit":"bb4c0e13d87c1700d5a1c477662edbef6b1f046b"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fcush-cdn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fcush-cdn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fcush-cdn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fcush-cdn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aleclarson","download_url":"https://codeload.github.com/aleclarson/cush-cdn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225010049,"owners_count":17406552,"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":["assets","cush","development","server"],"created_at":"2024-10-12T04:07:20.410Z","updated_at":"2025-05-11T04:30:38.202Z","avatar_url":"https://github.com/aleclarson.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cush-cdn v0.0.3\n\nLocal asset server for development. Built-in support for [cush][1].\n\n[1]: https://github.com/aleclarson/cush\n\n```js\n// Create the server.\nconst cdn = require('cush-cdn')(options);\n```\n\nThe server constructor takes [these options][2] and returns a [slush][3] instance.\n\nAdditional options:\n- `bucketDir: ?string` the directory where buckets are cached\n\n[2]: https://github.com/aleclarson/slush#options\n[3]: https://github.com/aleclarson/slush\n\n### Fetching an asset\n\nSend a GET request to `/b/path/to/example.js` with an `X-Bucket` header\nequal to the desired bucket's unique identifier.\n\n### Adding a project\n\n1. Save assets in your project's `./assets/` directory\n\n2. Add a `.cushignore` file to the `./assets/` directory (optional)\n\n   - pattern syntax is detailed [here](https://github.com/aleclarson/recrawl#pattern-syntax)\n   - paths ignored by default are:\n     - `/.cushignore`\n     - `.DS_Store`\n     - `*.swp`\n\n3. Export the `bundles` object in your project's `cush.config.js`\n\n```js\nexports.bundles = {\n  'main.js': 'bundle.web.js',\n  'styles/main.css': {\n    name: 'bundle.css',\n    target: 'web',\n  }\n};\n```\n\n4. Register the project with `cush-cdn`\n\n```js\ncdn.addProject('/path/to/project');\n\n// Get the default bucket of your project by its name.\ncdn.getBucket('my-project');\n```\n\nIn the future, you may be able to share buckets between projects.\n\n## JavaScript API\n\n#### `loadProject(root: string): void`\n\nRegister a project with the server.\n\nIts default bucket is created (located at `./assets/`).\nIts bundles are registered with the default bucket.\n\n#### `dropProject(root: string): boolean`\n\nStop serving a project's assets.\n\nReturns true when a project exists.\n\n#### `getBucket(id: string): ?Bucket`\n\nGet a `Bucket` object by its unique identifier.\n\n#### `loadBucket(id: string, options: ?Object)`\n\nCreate a `Bucket` object.\n\nThe given `id` string must be unique.\n\nAvailable options:\n- `root: string`\n- `only: ?string[]` whitelist for filenames\n- `skip: ?string[]` blacklist for filenames\n\n#### `dropBucket(id: string): boolean`\n\nDestroy a `Bucket` by its unique identifier.\n\nReturns true when a bucket exists.\n\n### `Bucket` class\n\nProperties:\n- `id: string`\n- `root: string`\n- `dest: string`\n- `only: string[]`\n- `skip: string[]`\n- `events: EventEmitter`\n\nThe `events` property is an [se.EventEmitter](https://github.com/aleclarson/socket-events/blob/master/events.js#L3-L65) object.\n\n#### `has(name: string): boolean`\n\nReturns true if the asset exists.\n\n#### `get(name: string): ?string|function`\n\nWhen an asset is cached on disk, its cached filename is returned.\nThis filename can be used to read the asset from its bucket.\n\n#### `patch(values: Object): void`\n\nPatch the asset manifest.\n\nSee the `PATCH /b/assets.json` section for more details.\n\n#### `put(name: string, value: string|function): void`\n\nAdd an asset to the bucket.\n\nWhen the `value` is a function, it's passed the HTTP response object\nand may return a promise, readable stream, string, or falsy.\n\n#### `delete(name: string): void`\n\nRemove an asset from the bucket.\n\n#### `query(options: Object): Promise\u003cObject\u003e`\n\nUse [`wch.query`](https://github.com/aleclarson/wch) on the bucket root.\n\nThe query API is currently undocumented.\n\n## REST API\n\nAll `/b/` requests must include an `X-Bucket` header.\n\n### `GET /b/[asset]`\n\nFetch an asset.\n\nThe response headers include:\n- `Content-Type`\n- `Content-Length`\n- `Cache-Control: no-store`\n\n### `GET /b/assets.json`\n\nFetch the asset manifest, which maps asset names to their production identifiers.\n\nWhen a value is `true`, the asset name is used as-is in production.\n\nBy setting the `accepts` header to `text/event-stream`, you will receive\nchange events as they happen. The [socket-events][4] protocol is used.\n\n[4]: https://github.com/aleclarson/socket-events#event-serialization\n\n### `PATCH /b/assets.json`\n\nPatch the asset manifest.\n\nThe request body must be a JSON object where the keys are asset names\nand each value is a string, `true` literal, or `null` literal.\n\nWhen a value is `null`, the asset is deleted from the bucket.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FcushJS%2Fcush-cdn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FcushJS%2Fcush-cdn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FcushJS%2Fcush-cdn/lists"}