{"id":18974967,"url":"https://github.com/bufferapp/buffer-js-static-assets","last_synced_at":"2026-04-08T18:30:17.320Z","repository":{"id":65840772,"uuid":"162277022","full_name":"bufferapp/buffer-js-static-assets","owner":"bufferapp","description":null,"archived":false,"fork":false,"pushed_at":"2019-01-22T11:27:53.000Z","size":73,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-12T10:13:18.435Z","etag":null,"topics":[],"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/bufferapp.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":"2018-12-18T11:20:48.000Z","updated_at":"2019-01-22T11:27:55.000Z","dependencies_parsed_at":"2023-02-13T14:10:12.040Z","dependency_job_id":null,"html_url":"https://github.com/bufferapp/buffer-js-static-assets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fbuffer-js-static-assets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fbuffer-js-static-assets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fbuffer-js-static-assets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fbuffer-js-static-assets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bufferapp","download_url":"https://codeload.github.com/bufferapp/buffer-js-static-assets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239972513,"owners_count":19727394,"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-11-08T15:16:50.385Z","updated_at":"2026-04-08T18:30:17.271Z","avatar_url":"https://github.com/bufferapp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# buffer-js-static-assets\n\n[![Build Status](https://travis-ci.org/bufferapp/buffer-js-static-assets.svg?branch=master)](https://travis-ci.org/bufferapp/buffer-js-static-assets)\n\n## Installation\n\nInstall the package\n\n```\nnpm install @bufferapp/static-assets\n```\n\n## Usage\n\nTo utilize the `staticUrl` function, you'll need to first initialize the\nstatic assets manager:\n\n```js\nconst { initStaticAssets } = require('@bufferapp/static-assets')\n\ninitStaticAssets()\n  .then(() =\u003e {\n    // Now that we have loaded the static assets we can serve requests\n    app.listen(8080, () =\u003e console.log('Server started!'))\n  })\n```\n\nAlternatively, you can call the `initStaticAssetsSync` function to perform\na synchronous load of the static assets file which is blocking:\n\n```js\ninitStaticAssetsSync()\napp.listen(8080, () =\u003e console.log('Server started!'))\n```\n\nOnce the library is initialized, using the exported `staticUrl` function:\n\n```js\nconst { staticUrl } = require('@bufferapp/static-assets')\n\napp.get('/sweet', (req, res) =\u003e {\n  res.render('sweet-template', {\n    headerImage: staticUrl('img/sweet-header4.png'),\n    script: staticUrl('js/sweet-bundle.js'),\n  })\n})\n```\n\n### Options\n\nWe have a few configuration options that can be passed to `initStaticAssets` in\na single object argument (ex. `initStaticAssets({ path: '/static' })`):\n\n* `staticAssetVersionsFilename` - The name of the static asset manifest file.\n* `staticAssetDirLocal` - The relative path where static assets are served during local dev. Usually via express-static.\n* `staticAssetDirCDN` - This is the directory relative to your working directory where your static assets are saved. This is used to look up static files in the manifest (See manifest section below).\n\n### Static Asset Manifest\n\nThe format of the static asset manifest should be the same as default JSON\nformat that [`buffer-static-upload`](https://github.com/bufferapp/buffer-static-upload)\noutputs.\n\nThis format is a key-value pair of:\n\n```json\n\"relative path to local file from working directory\": \"remote URL for that file\"\n```\n\nHere's an example:\n\n```json\n{\n  \"public/css/style.css\": \"https://static.buffer.com/my-app/public/css/style.1234567890.css\",\n  \"public/img/brand.png\": \"https://static.buffer.com/my-app/public/img/brand.png\"\n}\n```\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufferapp%2Fbuffer-js-static-assets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbufferapp%2Fbuffer-js-static-assets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufferapp%2Fbuffer-js-static-assets/lists"}