{"id":16611448,"url":"https://github.com/shufo/cdn","last_synced_at":"2025-08-22T17:16:38.502Z","repository":{"id":9288926,"uuid":"61501045","full_name":"shufo/cdn","owner":"shufo","description":"CDN Assets Manager for Elixir","archived":false,"fork":false,"pushed_at":"2025-08-11T17:39:12.000Z","size":54,"stargazers_count":15,"open_issues_count":16,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-16T19:46:51.902Z","etag":null,"topics":["elixir"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/cdn/","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shufo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2016-06-19T21:23:46.000Z","updated_at":"2023-11-22T21:51:24.000Z","dependencies_parsed_at":"2024-05-30T16:56:05.522Z","dependency_job_id":"d3a98ba8-3f0f-4a65-ab87-00269ea5acb5","html_url":"https://github.com/shufo/cdn","commit_stats":{"total_commits":44,"total_committers":5,"mean_commits":8.8,"dds":"0.20454545454545459","last_synced_commit":"9c4e8dbf07fb30b240c1cb4418fde4aacdd9d78e"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/shufo/cdn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shufo%2Fcdn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shufo%2Fcdn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shufo%2Fcdn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shufo%2Fcdn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shufo","download_url":"https://codeload.github.com/shufo/cdn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shufo%2Fcdn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271673387,"owners_count":24800708,"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-08-22T02:00:08.480Z","response_time":65,"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":["elixir"],"created_at":"2024-10-12T01:37:34.503Z","updated_at":"2025-08-22T17:16:38.452Z","avatar_url":"https://github.com/shufo.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elixir CDN Assets Manager\n\n[![Build Status](https://travis-ci.org/shufo/cdn.svg?branch=master)](https://travis-ci.org/shufo/cdn)\n[![hex.pm version](https://img.shields.io/hexpm/v/cdn.svg)](https://hex.pm/packages/cdn)\n[![hex.pm](https://img.shields.io/hexpm/l/cdn.svg)](https://github.com/shufo/cdn/blob/master/LICENSE)\n\n### Content Delivery Network Package for Elixir/Phoenix.\n\nThis package provides the developer the ability to upload assets to a CDN with single mix command.  \nInspired by [Vinelab/cdn](https://github.com/Vinelab/cdn).\n\n## Overview\n\n\u003cimg src=\"https://raw.githubusercontent.com/wiki/shufo/cdn/img/upload.gif\" width=\"600\"\u003e\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed as:\n\n1. Add cdn to your list of dependencies in `mix.exs`:\n\n```elixir\n{:cdn, \"~\u003e 0.1.0\"}\n```\n\n## Configuration\n\nFirstly this package is relies on [ex_aws](https://github.com/CargoSense/ex_aws) then setting `ex_aws` before configuration.\n\n`:ex_aws` must always be added to your applications list.\n\n```elixir\ndef application do\n  [applications: [:ex_aws, :httpoison, :poison]]\nend\n```\n\nExport your AWS access key ID and Secret to your environmet variable(recommend)\n\n```\nexport AWS_ACCESS_KEY_ID=your_access_key_id\nexport AWS_SECRET_ACCESS_KEY=your_secret_access_key\n```\n\nor set config in mix.exs.\n\n```elixir\nconfig :ex_aws,\n  access_key_id: [{:system, \"AWS_ACCESS_KEY_ID\"}, :instance_role],\n  secret_access_key: [{:system, \"AWS_SECRET_ACCESS_KEY\"}, :instance_role]\n```\n\nand set your region.\n\n```elixir\nconfig :ex_aws,\n  region: \"us-east-1\"\n```\n\nAfter that Configure `:cdn` in `config.exs`.(Example)\n\n```elixir\nconfig :cdn,  bucket: \"assets.foo\",\n              include: [\n                directories: [\"priv/static\", \"public/bin\"],\n                patterns: [\"**/*\", \"**/*.css\"],\n                hidden: true\n              ],\n              exclude: [\n                directories: [],\n                patterns: [],\n                hidden: true\n              ],\n              acl: :public_read,\n              cache_control: \"max-age=#{86400 * 30}\",\n              expires_after: 86400 * 30,\n              cloudfront_url: \"https://asset.s3.amazonaws.com\",\n              bypass: false\n```\n\nThis means it should be include files matched pattern `**/*` or `**/*.css` in `priv/static` or `public/bin`. Also includes hidden files(filename starts with `.`). And base url for asset helper is `https://asset.s3.amazonaws.com`, but always outputs local file url for asset helper because `bypass` is false.   \n\n- `bucket`: A bucket name of s3\n- `include`: Setting for upload target\n  - `directories`: List of upload directory(`default`: `[\"priv/static\"]`)\n  - `patterns`: List of upload pattern(`default`: `[\"**/*\"]`)\n  - `hidden`: Include hidden files or not\n- `exclude`: Exclude targets\n- `acl`: Default acl for assets\n- `cloudfront_url`: URL of CDN endopoint (e.g. `https://cloudfonrt.net`)\n- `bypass`: Return local asset if `bypass` is `true` in cdn helper.\n\n## Usage\n\n### Commands\n\n- Upload to S3\n\n```elixir\nmix cdn.push\n```\n\n- Empty bucket\n\n```elixir\nmix cdn.empty\n```\n\n### Asset Helper\n\nImport CDN Helper to your dependency\n\n- Phoenix\n\n`web.ex`\n\n```elixir\ndef view do\n  quote do\n    ...\n    # Import CDN helper\n    import Cdn.Helpers\n    ...\n  end\nend\n```\n\nthen you can load static file like this.\n\n```elixir\n\u003c%= cdn(static_path(@conn, \"/css/app.css\")) %\u003e\n\n# MIX_ENV=dev\n\u003c%= cdn(static_path(@conn, \"/css/app.css\")) %\u003e #=\u003e \"/css/app.css\"\n\n# MIX_ENV=prod\n\u003c%= cdn(static_path(@conn, \"/css/app.css\")) %\u003e #=\u003e \"https://assets.cloudfront.net/css/app.css\"\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshufo%2Fcdn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshufo%2Fcdn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshufo%2Fcdn/lists"}