├── .dockerignore ├── .env.example ├── .gitignore ├── .prettierignore ├── Dockerfile ├── LICENSE ├── README.md ├── bun.lock ├── config.example.json ├── config.schema.json ├── fly.example.toml ├── index.ts ├── lib └── request-helpers.ts ├── package.json ├── packages └── cli │ ├── .gitignore │ ├── README.md │ ├── commands │ └── upload.ts │ ├── index.ts │ ├── package.json │ └── tsconfig.json └── tsconfig.json /.dockerignore: -------------------------------------------------------------------------------- 1 | # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore 2 | 3 | # Logs 4 | 5 | logs 6 | _.log 7 | npm-debug.log_ 8 | yarn-debug.log* 9 | yarn-error.log* 10 | lerna-debug.log* 11 | .pnpm-debug.log* 12 | 13 | # Caches 14 | 15 | .cache 16 | 17 | # Diagnostic reports (https://nodejs.org/api/report.html) 18 | 19 | report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json 20 | 21 | # Runtime data 22 | 23 | pids 24 | _.pid 25 | _.seed 26 | *.pid.lock 27 | 28 | # Directory for instrumented libs generated by jscoverage/JSCover 29 | 30 | lib-cov 31 | 32 | # Coverage directory used by tools like istanbul 33 | 34 | coverage 35 | *.lcov 36 | 37 | # nyc test coverage 38 | 39 | .nyc_output 40 | 41 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 42 | 43 | .grunt 44 | 45 | # Bower dependency directory (https://bower.io/) 46 | 47 | bower_components 48 | 49 | # node-waf configuration 50 | 51 | .lock-wscript 52 | 53 | # Compiled binary addons (https://nodejs.org/api/addons.html) 54 | 55 | build/Release 56 | 57 | # Dependency directories 58 | 59 | node_modules/ 60 | jspm_packages/ 61 | 62 | # Snowpack dependency directory (https://snowpack.dev/) 63 | 64 | web_modules/ 65 | 66 | # TypeScript cache 67 | 68 | *.tsbuildinfo 69 | 70 | # Optional npm cache directory 71 | 72 | .npm 73 | 74 | # Optional eslint cache 75 | 76 | .eslintcache 77 | 78 | # Optional stylelint cache 79 | 80 | .stylelintcache 81 | 82 | # Microbundle cache 83 | 84 | .rpt2_cache/ 85 | .rts2_cache_cjs/ 86 | .rts2_cache_es/ 87 | .rts2_cache_umd/ 88 | 89 | # Optional REPL history 90 | 91 | .node_repl_history 92 | 93 | # Output of 'npm pack' 94 | 95 | *.tgz 96 | 97 | # Yarn Integrity file 98 | 99 | .yarn-integrity 100 | 101 | # dotenv environment variable files 102 | 103 | .env 104 | .env.development.local 105 | .env.test.local 106 | .env.production.local 107 | .env.local 108 | 109 | # parcel-bundler cache (https://parceljs.org/) 110 | 111 | .parcel-cache 112 | 113 | # Next.js build output 114 | 115 | .next 116 | out 117 | 118 | # Nuxt.js build / generate output 119 | 120 | .nuxt 121 | dist 122 | 123 | # Gatsby files 124 | 125 | # Comment in the public line in if your project uses Gatsby and not Next.js 126 | 127 | # https://nextjs.org/blog/next-9-1#public-directory-support 128 | 129 | # public 130 | 131 | # vuepress build output 132 | 133 | .vuepress/dist 134 | 135 | # vuepress v2.x temp and cache directory 136 | 137 | .temp 138 | 139 | # Docusaurus cache and generated files 140 | 141 | .docusaurus 142 | 143 | # Serverless directories 144 | 145 | .serverless/ 146 | 147 | # FuseBox cache 148 | 149 | .fusebox/ 150 | 151 | # DynamoDB Local files 152 | 153 | .dynamodb/ 154 | 155 | # TernJS port file 156 | 157 | .tern-port 158 | 159 | # Stores VSCode versions used for testing VSCode extensions 160 | 161 | .vscode-test 162 | 163 | # yarn v2 164 | 165 | .yarn/cache 166 | .yarn/unplugged 167 | .yarn/build-state.yml 168 | .yarn/install-state.gz 169 | .pnp.* 170 | 171 | # IntelliJ based IDEs 172 | .idea 173 | 174 | # Finder (MacOS) folder config 175 | .DS_Store 176 | 177 | # App specific config 178 | config.example.json 179 | fly.example.toml 180 | LICENSE 181 | README.md 182 | packages/ 183 | !packages/*/package.json -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | AWS_ACCESS_KEY_ID= 2 | AWS_SECRET_ACCESS_KEY= 3 | AWS_REGION=auto 4 | AWS_ENDPOINT=https://fly.storage.tigris.dev -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore 2 | 3 | # Logs 4 | 5 | logs 6 | _.log 7 | npm-debug.log_ 8 | yarn-debug.log* 9 | yarn-error.log* 10 | lerna-debug.log* 11 | .pnpm-debug.log* 12 | 13 | # Caches 14 | 15 | .cache 16 | 17 | # Diagnostic reports (https://nodejs.org/api/report.html) 18 | 19 | report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json 20 | 21 | # Runtime data 22 | 23 | pids 24 | _.pid 25 | _.seed 26 | *.pid.lock 27 | 28 | # Directory for instrumented libs generated by jscoverage/JSCover 29 | 30 | lib-cov 31 | 32 | # Coverage directory used by tools like istanbul 33 | 34 | coverage 35 | *.lcov 36 | 37 | # nyc test coverage 38 | 39 | .nyc_output 40 | 41 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 42 | 43 | .grunt 44 | 45 | # Bower dependency directory (https://bower.io/) 46 | 47 | bower_components 48 | 49 | # node-waf configuration 50 | 51 | .lock-wscript 52 | 53 | # Compiled binary addons (https://nodejs.org/api/addons.html) 54 | 55 | build/Release 56 | 57 | # Dependency directories 58 | 59 | node_modules/ 60 | jspm_packages/ 61 | 62 | # Snowpack dependency directory (https://snowpack.dev/) 63 | 64 | web_modules/ 65 | 66 | # TypeScript cache 67 | 68 | *.tsbuildinfo 69 | 70 | # Optional npm cache directory 71 | 72 | .npm 73 | 74 | # Optional eslint cache 75 | 76 | .eslintcache 77 | 78 | # Optional stylelint cache 79 | 80 | .stylelintcache 81 | 82 | # Microbundle cache 83 | 84 | .rpt2_cache/ 85 | .rts2_cache_cjs/ 86 | .rts2_cache_es/ 87 | .rts2_cache_umd/ 88 | 89 | # Optional REPL history 90 | 91 | .node_repl_history 92 | 93 | # Output of 'npm pack' 94 | 95 | *.tgz 96 | 97 | # Yarn Integrity file 98 | 99 | .yarn-integrity 100 | 101 | # dotenv environment variable files 102 | 103 | .env 104 | .env.development.local 105 | .env.test.local 106 | .env.production.local 107 | .env.local 108 | 109 | # parcel-bundler cache (https://parceljs.org/) 110 | 111 | .parcel-cache 112 | 113 | # Next.js build output 114 | 115 | .next 116 | out 117 | 118 | # Nuxt.js build / generate output 119 | 120 | .nuxt 121 | dist 122 | 123 | # Gatsby files 124 | 125 | # Comment in the public line in if your project uses Gatsby and not Next.js 126 | 127 | # https://nextjs.org/blog/next-9-1#public-directory-support 128 | 129 | # public 130 | 131 | # vuepress build output 132 | 133 | .vuepress/dist 134 | 135 | # vuepress v2.x temp and cache directory 136 | 137 | .temp 138 | 139 | # Docusaurus cache and generated files 140 | 141 | .docusaurus 142 | 143 | # Serverless directories 144 | 145 | .serverless/ 146 | 147 | # FuseBox cache 148 | 149 | .fusebox/ 150 | 151 | # DynamoDB Local files 152 | 153 | .dynamodb/ 154 | 155 | # TernJS port file 156 | 157 | .tern-port 158 | 159 | # Stores VSCode versions used for testing VSCode extensions 160 | 161 | .vscode-test 162 | 163 | # yarn v2 164 | 165 | .yarn/cache 166 | .yarn/unplugged 167 | .yarn/build-state.yml 168 | .yarn/install-state.gz 169 | .pnp.* 170 | 171 | # IntelliJ based IDEs 172 | .idea 173 | 174 | # Finder (MacOS) folder config 175 | .DS_Store 176 | 177 | # App specific config 178 | config.json 179 | config.jsonc 180 | fly.toml -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .dockerignore -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = docker/dockerfile:1 2 | 3 | # Adjust BUN_VERSION as desired 4 | ARG BUN_VERSION=1.2.0 5 | FROM oven/bun:${BUN_VERSION}-slim AS base 6 | 7 | LABEL fly_launch_runtime="Bun" 8 | 9 | # Bun app lives here 10 | WORKDIR /app 11 | 12 | # Set production environment 13 | ENV NODE_ENV="production" 14 | 15 | 16 | # Throw-away build stage to reduce size of final image 17 | FROM base AS build 18 | 19 | # Install packages needed to build node modules 20 | RUN apt-get update -qq && \ 21 | apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3 22 | 23 | # Install node modules 24 | COPY bun.lock package.json packages/cli/package.json ./ 25 | RUN bun install --omit=dev --omit=peer 26 | 27 | # Copy application code 28 | COPY . . 29 | 30 | 31 | # Final stage for app image 32 | FROM base 33 | 34 | # Copy built application 35 | COPY --from=build /app /app 36 | 37 | # Start the server by default, this can be overwritten at runtime 38 | EXPOSE 3000 39 | CMD [ "bun", "index.ts" ] 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bun-tastic: static site hosting with Bun + Tigris 2 | 3 | A high-performance web server that lets you serve multiple static websites from different S3 buckets through a single server. It's perfect for managing multiple static sites with their individual domains while keeping the hosting simple and efficient. 4 | 5 | It uses [Tigris](https://www.tigrisdata.com/) for object storage and benefits from its global caching. 6 | 7 | Bun-tastic uses Fly.io as its default deployment option, allowing you to set up global compute with a single command. 8 | 9 | In other words, it's a high-performance, scalable, and efficient solution for hosting multiple static websites on your own terms. 10 | 11 | > 📚 **Tip**: Use GitHub's table of contents feature to navigate this document easily! Click the menu icon next to the README title above. 12 | > ![tip-illustration](https://i.imgur.com/16RFa09.png) 13 | 14 | ## Features and Benefits 🔥 15 | 16 | - Serve multiple static websites from one application 17 | - Global distributed caching and compute 18 | - Easy configuration through JSON 19 | - Brotli & zstd compression (via Fly Proxy), with response streaming 20 | - Built-in monitoring with Grafana dashboard (via Fly) 21 | - Smart path handling with automatic index.html resolution 22 | - Built on Bun's native S3 client and web server, thereby benefiting [from Bun's fast performance](https://x.com/jarredsumner/status/1877660347709972484) 23 | - It's Lightweight. It uses zero dependency and can run on a single CPU with 256MB RAM 24 | - Posssibility to add and configure middleware and that can handle extra needs like authorization, redirect/rewrite rules, etc. 25 | - Possible cheap/affordable hosting with volume-based licensing on Fly and affordable Tigris storage. 26 | 27 | ### Planned Features 28 | 29 | - CLI/API for simplified site uploads (with resumability) 30 | - Per-machine/VM caching with cache invalidation (potential performance boost) 31 | - 103 Early Hints support (more efficient page load times) 32 | - Easy setup/config to run on multi-cores 33 | - Configurable bot request blocking 34 | 35 | ## Performance 36 | 37 | It's fast! But better to try it for yourself. Here's a sample from a local test: 38 | 39 | ![load testing and measuring response time](https://cdn.hashnode.com/res/hashnode/image/upload/v1736875740269/531f0b7a-5b22-44f6-9156-57b5619f63f9.webp) 40 | 41 | You can see that the response time is very low and more than have returned in less than 100ms, for a response of 6KiB in size. Now deploy this in the regions you want to get lower latency and faster response times. 42 | 43 | > The server is a shared VM with 256MB RAM and 1 CPU running on fly.io. Deployed region is in Sweden (arn). 44 | > Tested on a 2021 MacBook Pro with M1 chip. Average internet speed 200 - 300Mbps. 45 | > Try it yourself at https://first.flycd.dev or https://second.flycd.dev 46 | 47 | Here's a video of me sampling the load and response times: 48 | 49 | ![GIF showing the output from my terminal load testing and ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zy6zc10dg96vv3qel94u.gif) 50 | 51 | ## Usage Instructions 52 | 53 | Here's a video showing how to use it with the CLI (Quickstart demo): 54 | 55 | [![Quickstart demo of bun-tastic CLI](https://img.youtube.com/vi/oRommxCpHM4/0.jpg)](https://www.youtube.com/watch?v=oRommxCpHM4) 56 | 57 | > **Click to watch the video** 58 | 59 | ### Prerequisites 60 | 61 | - Bun >= 1.2.0 62 | - S3-compatible storage (like Tigris). Tigris is recommended for its global/distributed caching support. 63 | - An account on Fly.io (optional) 64 | 65 | ### Configuration 66 | 67 | 1. Clone this repository 68 | 2. Copy config.example.json to config.json: 69 | ```bash 70 | cp config.example.json config.json 71 | ``` 72 | 3. Update config.json with your domain to bucket mappings: 73 | ```json 74 | { 75 | "example.com": "my-bucket-name", 76 | "another-site.com": "another-bucket-name" 77 | } 78 | ``` 79 | 4. If you intend to run it local, copy `.env.example` to `.env` and fill in your S3 credentials: 80 | ```bash 81 | cp .env.example .env 82 | ``` 83 | 5. For Fly.io deployment, add the secrets to the env after you deployed or created the app. You can add it from the dashboard or CLI. Here is an example using CLI: 84 | ```bash 85 | fly secrets set AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_REGION=auto AWS_ENDPOINT=https://fly.storage.tigris.dev 86 | ``` 87 | 88 | ### Running Locally 89 | 90 | To run bun-tastic locally ensure you have the minimum required version for Bun (`Bun >= 1.1.43`), the correct `.env` file and values, and the config (config.json). 91 | 92 | Once you have confirmed that you have all of that in place, run `bun index.ts` to start the server. 93 | 94 | > You can configure a local domain in `/etc/hosts` and use a tool like [Caddy](https://caddyserver.com/) to proxy the requests to the local server. 95 | 96 | ### Deployment to fly.io 97 | 98 | There's a sample `fly.toml` file in the repo, i.e. **fly.example.toml**. Rename it to `fly.toml` or create your own `fly.toml` file with same content. Edit it and set the name for the app, and optionally change the machines type (or other settings) to match your needs. 99 | 100 | ```diff 101 | # uncomment below and specify the name for your app 102 | - # app = 'bun-static-host' 103 | + app = 'your-own-app-name' 104 | # specify the primary region for your app 105 | primary_region = 'arn' 106 | 107 | [build] 108 | 109 | [http_service] 110 | internal_port = 3000 111 | force_https = true 112 | auto_stop_machines = 'stop' 113 | auto_start_machines = true 114 | min_machines_running = 0 115 | processes = ['app'] 116 | 117 | [[vm]] 118 | memory = '256mb' 119 | cpu_kind = 'shared' 120 | cpus = 1 121 | ``` 122 | 123 | Then run `fly launch --no-deploy` to launch/scaffold the project. 124 | 125 | Next, set the secrets using the command in case you haven't done that already: 126 | 127 | ```bash 128 | fly secrets set AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_REGION=auto AWS_ENDPOINT=https://fly.storage.tigris.dev 129 | ``` 130 | 131 | Finally, run `fly deploy` to deploy the app. 132 | 133 | You can scale the app to multiple machines and regions if needed (see [docs for details](https://fly.io/docs/flyctl/scale-count/)). 134 | 135 | ### Domains, DNS, and TLS Certificates 136 | 137 | For the domain configuration, you'll need to set up DNS records for each domain you want to serve. Fly.io can handle TLS certificates for you, but you'll need to set up the DNS records to point to the app's IP address or Fly's subdomain. 138 | 139 | You'll find more info on how to do this in their [docs](https://fly.io/docs/networking/custom-domain/). If you use Cloudflare for DNS, make sure you read this [section in that page](https://fly.io/docs/networking/custom-domain/#i-use-cloudflare-and-there-seems-to-be-a-problem-issuing-or-validating-my-fly-io-tls-certificate). 140 | 141 | ## Uploading Files With Buntastic CLI 142 | 143 | While you can upload files to your bucket using the web console from Tigris, or the AWS CLI, you can also use the _Buntastic_ CLI to upload files to your Tigris/S3 bucket. It is designed to be simple to use, and also uploads faster compared to the other options. 144 | 145 | You can use the CLI for your daily task, or use it in your CI/CD pipeline. 146 | 147 | More details about how to install and use it can be found in the [CLI's README](/packages/cli/README.md). 148 | 149 | ## FAQ 150 | 151 | Here are some common questions and answers.Please, if you have more question or have doubts/critic, please start a discussion :) 152 | 153 | ### Q: Why use bun-tastic instead of traditional static hosting? 154 | 155 | It's fine to use traditional hosting service but if you're looking to selfhost your own static sites from a single (or distributed) machine, this is **FOR YOU**. 156 | 157 | You have the flexibility to configure as much redirect/rewrite rules as you want. You could also add authorization/authentication rules to specific domains and routes, which can help you share content with specific users. 158 | 159 | It's ideal for agencies, freelancers, or individuals who have many clients and projects, and they can easily manage them from one server and save cost. 160 | 161 | ### Q: Isn't it more expensive to selfhost? 162 | 163 | It depends on your usage. 164 | 165 | If you have just one website that gets a few hundred visits per day, it's probably cheaper to use a traditional static site host. However, if you have multiple websites or a high traffic site, self-hosting can be more cost-effective. 166 | 167 | When you combine the flexibility and control of self-hosting, with the affordable cost of Tigris storage, volume-based licensing on [Fly.io](https://fly.io/pricing/), and the ability to scale to zero, then you can save a lot of money. 168 | 169 | ### Q: What are the benefits of bun-tastic? 170 | 171 | See the [benefits section](#features-and-benefits-). 172 | 173 | ### Q: Can I use any S3-compatible storage? 174 | 175 | Yes, any S3-compatible storage service will work. 176 | 177 | ## Contributing 178 | 179 | Feel free to open pull requests if there's an issue! Use GitHub Discussion for feature requests or to discuss the project or potential defects. 180 | 181 | ## Sponsors 182 | 183 | If you find this project useful, please consider sponsoring it. Your support helps me continue developing and maintaining this project. I haven't set up a Patreon or similar platform yet, but I'm open to suggestions. In the meantime, DM me on [Twitter/X](https://x.com/p_mbanugo), [LinkedIn](https://www.linkedin.com/in/pmbanugo/), or [Bluesky](https://bsky.app/profile/pmbanugo.me). 184 | -------------------------------------------------------------------------------- /bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "workspaces": { 4 | "": { 5 | "name": "@pmbanugo/buntastic", 6 | "devDependencies": { 7 | "@types/bun": "^1.2.0", 8 | }, 9 | "peerDependencies": { 10 | "typescript": "^5.7.3", 11 | }, 12 | }, 13 | "packages/cli": { 14 | "name": "@pmbanugo/buntastic-cli", 15 | "version": "0.0.1-canary.4", 16 | "bin": { 17 | "buntastic": "index.ts" 18 | }, 19 | "dependencies": { 20 | "sade": "^1.8.1", 21 | }, 22 | "devDependencies": { 23 | "@types/bun": "^1.2.0", 24 | }, 25 | "peerDependencies": { 26 | "typescript": "^5.7.3", 27 | }, 28 | }, 29 | }, 30 | "packages": { 31 | "@pmbanugo/buntastic-cli": ["@pmbanugo/buntastic-cli@workspace:packages/cli"], 32 | 33 | "@types/bun": ["@types/bun@1.2.0", "", { "dependencies": { "bun-types": "1.2.0" } }, "sha512-5N1JqdahfpBlAv4wy6svEYcd/YfO2GNrbL95JOmFx8nkE6dbK4R0oSE5SpBA4vBRqgrOUAXF8Dpiz+gi7r80SA=="], 34 | 35 | "@types/node": ["@types/node@22.10.9", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-Ir6hwgsKyNESl/gLOcEz3krR4CBGgliDqBQ2ma4wIhEx0w+xnoeTq3tdrNw15kU3SxogDjOgv9sqdtLW8mIHaw=="], 36 | 37 | "@types/ws": ["@types/ws@8.5.13", "", { "dependencies": { "@types/node": "*" } }, "sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA=="], 38 | 39 | "bun-types": ["bun-types@1.2.0", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-KEaJxyZfbV/c4eyG0vyehDpYmBGreNiQbZIqvVHJwZ4BmeuWlNZ7EAzMN2Zcd7ailmS/tGVW0BgYbGf+lGEpWw=="], 40 | 41 | "mri": ["mri@1.2.0", "", {}, "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA=="], 42 | 43 | "sade": ["sade@1.8.1", "", { "dependencies": { "mri": "^1.1.0" } }, "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A=="], 44 | 45 | "typescript": ["typescript@5.7.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw=="], 46 | 47 | "undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="], 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /config.example.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./config.schema.json", 3 | "example.com": "example-site" 4 | } 5 | -------------------------------------------------------------------------------- /config.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "description": "Domain to site name mapping configuration", 5 | "additionalProperties": { 6 | "type": "string", 7 | "description": "Site name associated with the domain" 8 | }, 9 | "patternProperties": { 10 | "^[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$": { 11 | "type": "string" 12 | } 13 | }, 14 | "examples": [ 15 | { 16 | "first.flycd.dev": "first-site", 17 | "second.flycd.dev": "astro-site" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /fly.example.toml: -------------------------------------------------------------------------------- 1 | # fly.toml app configuration file generated for bun-static-host on 2025-01-13T14:53:11+01:00 2 | # 3 | # See https://fly.io/docs/reference/configuration/ for information about how to use this file. 4 | # 5 | 6 | # uncomment below and specify the name for your app 7 | # app = 'bun-static-host' 8 | # specify the primary region for your app 9 | primary_region = 'arn' 10 | 11 | [build] 12 | 13 | [http_service] 14 | internal_port = 3000 15 | force_https = true 16 | auto_stop_machines = 'stop' 17 | auto_start_machines = true 18 | min_machines_running = 0 19 | processes = ['app'] 20 | 21 | [[vm]] 22 | memory = '256mb' 23 | cpu_kind = 'shared' 24 | cpus = 1 25 | -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | import { s3, type S3Stats } from "bun"; 2 | import { extractPath } from "./lib/request-helpers"; 3 | import domains from "./config.json" with { type: "json" }; 4 | 5 | const server = Bun.serve({ 6 | async fetch(req) { 7 | const host = req.headers.get("host"); 8 | if (!host) { 9 | return new Response("No host header found", { status: 400 }); 10 | } 11 | 12 | //@ts-ignore 13 | const bucket = domains[host]; 14 | if (!bucket) { 15 | return new Response("Unknown host", { status: 400 }); 16 | } 17 | 18 | const fileKey = extractPath(req.url); 19 | const file = s3.file(fileKey, { bucket }); 20 | try { 21 | const stat = await file.stat(); 22 | 23 | // Check If-None-Match against current S3 ETag 24 | const ifNoneMatch = req.headers.get("If-None-Match"); 25 | if (ifNoneMatch === stat.etag) { 26 | return new Response(null, { status: 304 }); 27 | } 28 | // Check If-Modified-Since against S3 Last-Modified 29 | const ifModifiedSince = req.headers.get("If-Modified-Since"); 30 | if (ifModifiedSince && new Date(ifModifiedSince) >= stat.lastModified) { 31 | return new Response(null, { status: 304 }); 32 | } 33 | 34 | const headers = await getHeaders(stat); 35 | return new Response(file.stream(), { 36 | headers, 37 | }); 38 | } catch (error) { 39 | if ( 40 | error instanceof Error && 41 | error.name === "S3Error" && 42 | "code" in error && 43 | error.code === "NoSuchKey" 44 | ) { 45 | return new Response(null, { status: 404 }); 46 | } 47 | 48 | console.error(error); 49 | return new Response(null, { status: 500 }); 50 | } 51 | }, 52 | }); 53 | 54 | console.log(`Listening on http://localhost:${server.port} ...`); 55 | 56 | const WEEK_IN_SECONDS = 7 * 24 * 60 * 60; // 7 days 57 | const DAY_IN_SECONDS = 86400; // 24 hours 58 | 59 | async function getHeaders(fileStat: S3Stats): Promise { 60 | const cacheControl = getCacheControl(fileStat.type); 61 | 62 | return { 63 | "Content-Type": fileStat.type, 64 | Etag: fileStat.etag, 65 | "Last-Modified": fileStat.lastModified.toUTCString(), 66 | "Cache-Control": cacheControl, 67 | }; 68 | } 69 | 70 | function getCacheControl(contentType: string): string { 71 | if (contentType === "text/html") { 72 | return "public, max-age=0"; 73 | } 74 | 75 | if ( 76 | contentType.match( 77 | /^(image|video|audio|font|application\/font-|application\/x-font-|text\/css|application\/javascript)/ 78 | ) 79 | ) { 80 | return `public, max-age=${WEEK_IN_SECONDS}, stale-while-revalidate=${DAY_IN_SECONDS}`; 81 | } 82 | 83 | /* A typical static site content, there aren't many file types 84 | * that would fall into this category - we could remove this default and explicitly handle all expected content types above 85 | */ 86 | return "public, max-age=0, must-revalidate"; 87 | } 88 | -------------------------------------------------------------------------------- /lib/request-helpers.ts: -------------------------------------------------------------------------------- 1 | export function extractPath(urlString: string): string { 2 | const url = new URL(urlString); 3 | let path = url.pathname; 4 | 5 | if (path.endsWith("/")) { 6 | path += "index.html"; 7 | } 8 | 9 | if (!isLikelyFileUrlUsingURL(path)) { 10 | path += "/index.html"; 11 | } 12 | 13 | return path; 14 | } 15 | 16 | function isLikelyFileUrlUsingURL(path: string) { 17 | return path.lastIndexOf(".") > path.lastIndexOf("/"); 18 | } 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pmbanugo/buntastic", 3 | "module": "index.ts", 4 | "type": "module", 5 | "devDependencies": { 6 | "@types/bun": "^1.2.0" 7 | }, 8 | "peerDependencies": { 9 | "typescript": "^5.7.3" 10 | }, 11 | "scripts": { 12 | "server:watch": "bun --watch index.ts", 13 | "cli:publish": "npm publish --tag canary --access public -w @pmbanugo/buntastic-cli" 14 | }, 15 | "workspaces": [ 16 | "packages/cli" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /packages/cli/.gitignore: -------------------------------------------------------------------------------- 1 | # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore 2 | 3 | # Logs 4 | 5 | logs 6 | _.log 7 | npm-debug.log_ 8 | yarn-debug.log* 9 | yarn-error.log* 10 | lerna-debug.log* 11 | .pnpm-debug.log* 12 | 13 | # Caches 14 | 15 | .cache 16 | 17 | # Diagnostic reports (https://nodejs.org/api/report.html) 18 | 19 | report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json 20 | 21 | # Runtime data 22 | 23 | pids 24 | _.pid 25 | _.seed 26 | *.pid.lock 27 | 28 | # Directory for instrumented libs generated by jscoverage/JSCover 29 | 30 | lib-cov 31 | 32 | # Coverage directory used by tools like istanbul 33 | 34 | coverage 35 | *.lcov 36 | 37 | # nyc test coverage 38 | 39 | .nyc_output 40 | 41 | # node-waf configuration 42 | 43 | .lock-wscript 44 | 45 | # Compiled binary addons (https://nodejs.org/api/addons.html) 46 | 47 | build/Release 48 | 49 | # Dependency directories 50 | 51 | node_modules/ 52 | jspm_packages/ 53 | 54 | # TypeScript cache 55 | 56 | *.tsbuildinfo 57 | 58 | # Optional npm cache directory 59 | 60 | .npm 61 | 62 | # Optional eslint cache 63 | 64 | .eslintcache 65 | 66 | # Optional stylelint cache 67 | 68 | .stylelintcache 69 | 70 | # Microbundle cache 71 | 72 | .rpt2_cache/ 73 | .rts2_cache_cjs/ 74 | .rts2_cache_es/ 75 | .rts2_cache_umd/ 76 | 77 | # Optional REPL history 78 | 79 | .node_repl_history 80 | 81 | # Output of 'npm pack' 82 | 83 | *.tgz 84 | 85 | # Yarn Integrity file 86 | 87 | .yarn-integrity 88 | 89 | # dotenv environment variable files 90 | 91 | .env 92 | .env.development.local 93 | .env.test.local 94 | .env.production.local 95 | .env.local 96 | 97 | # TernJS port file 98 | 99 | .tern-port 100 | 101 | # Stores VSCode versions used for testing VSCode extensions 102 | 103 | .vscode-test 104 | 105 | # yarn v2 106 | 107 | .yarn/cache 108 | .yarn/unplugged 109 | .yarn/build-state.yml 110 | .yarn/install-state.gz 111 | .pnp.* 112 | 113 | # IntelliJ based IDEs 114 | .idea 115 | 116 | # Finder (MacOS) folder config 117 | .DS_Store 118 | -------------------------------------------------------------------------------- /packages/cli/README.md: -------------------------------------------------------------------------------- 1 | # Buntastic CLI 2 | 3 | The Buntastic CLI is a command-line tool that enables you to upload files/folders to an S3 bucket. It is designed specifically for the [Buntastic](https://github.com/pmbanugo/bun-tastic) static site hosting service, but it can be use for uploading files to S3. 4 | 5 | Here's a video showing how to use it with the CLI (Quickstart demo): 6 | 7 | [![Quickstart demo of buntastic CLI](https://img.youtube.com/vi/oRommxCpHM4/0.jpg)](https://www.youtube.com/watch?v=oRommxCpHM4) 8 | 9 | Run the following command to install or upgrade the CLI: 10 | 11 | ```bash 12 | bun install -g @pmbanugo/buntastic-cli@latest 13 | ``` 14 | 15 | Once installed, you can access it using the `buntastic` command. For example, `buntastic --help` will display the help information. 16 | 17 | ```bash 18 | Usage 19 | $ buntastic [options] 20 | 21 | Available Commands 22 | upload Upload files to S3 23 | 24 | For more info, run any command with the `--help` flag 25 | $ buntastic upload --help 26 | 27 | Options 28 | -v, --version Displays current version 29 | -h, --help Displays this message 30 | 31 | Examples 32 | $ buntastic buntastic upload react-site --dir build 33 | ``` 34 | 35 | ## Configuration / Credentials 36 | 37 | The CLI reads the following environment variables for authentication: 38 | 39 | - `AWS_ACCESS_KEY_ID` or `S3_ACCESS_KEY_ID`: The access key ID to use for accessing the storage 40 | - `AWS_SECRET_ACCESS_KEY` or `S3_SECRET_ACCESS_KEY`: The secret access key 41 | - `AWS_REGION` or `S3_REGION`: The bucket's region 42 | - `AWS_BUCKET` or `S3_BUCKET`: S3 bucket name 43 | - `AWS_ENDPOINT` or `S3_ENDPOINT`: S3 endpoint/url 44 | - `AWS_SESSION_TOKEN` or `S3_SESSION_TOKEN`: Session token 45 | 46 | These variables are read from the process's environemnt or a **.env** file in the current working directory. 47 | 48 | ## Uploading Files 49 | 50 | Use the `upload` command to upload files to a bucket. These are the options available: 51 | 52 | ```bash 53 | $ buntastic upload --help 54 | 55 | Description 56 | Upload files to S3 57 | 58 | Usage 59 | $ buntastic upload [options] 60 | 61 | Options 62 | --file Single file to upload 63 | --dir Directory to upload recursively 64 | --region AWS region 65 | --endpoint S3 endpoint/url 66 | --access-key-id AWS access key ID 67 | --secret-access-key AWS secret access key 68 | -h, --help Displays this message 69 | 70 | Examples 71 | $ buntastic upload react-site --dir build --access-key-id $AWS_ACCESS_KEY_ID --secret-access-key $AWS_SECRET_ACCESS_KEY --endpoint $S3_URL --region $AWS_REGION 72 | ``` 73 | 74 | ### Examples 75 | 76 | To upload a single file, use the `--file` option: 77 | 78 | ```bash 79 | $ buntastic upload react-site --file build/index.html 80 | ``` 81 | 82 | To upload a directory, use the `--dir` option: 83 | 84 | ```bash 85 | $ buntastic upload react-site --dir build 86 | ``` 87 | 88 | Upload files files and specify the credentials using custom environment variables: 89 | 90 | ```bash 91 | $ buntastic upload react-site --dir build --access-key-id $ACCESS_KEY_ID --secret-access-key $SECRET_ACCESS_KEY --endpoint $AWS_ENDPOINT_URL_S3 --region auto 92 | ``` 93 | -------------------------------------------------------------------------------- /packages/cli/commands/upload.ts: -------------------------------------------------------------------------------- 1 | import { S3Client } from "bun"; 2 | import { basename } from "path"; 3 | import { readdir } from "node:fs/promises"; 4 | 5 | interface UploadOptions { 6 | file?: string; 7 | dir?: string; 8 | region?: string; 9 | "access-key-id"?: string; 10 | "secret-access-key"?: string; 11 | endpoint?: string; 12 | } 13 | 14 | export async function upload(bucket: string, opts: UploadOptions) { 15 | if (!opts.file && !opts.dir) { 16 | console.error("Either --file or --dir must be specified"); 17 | process.exit(1); 18 | } 19 | 20 | const client = new S3Client({ 21 | bucket: bucket, 22 | region: opts.region, 23 | accessKeyId: opts["access-key-id"], 24 | secretAccessKey: opts["secret-access-key"], 25 | endpoint: opts.endpoint, 26 | }); 27 | 28 | // File takes precedence 29 | if (opts.file) { 30 | const key = basename(opts.file); 31 | // TODO: handle errors, especially if file doesn't exist 32 | await client.write(key, Bun.file(opts.file)); 33 | console.log(`✓ Uploaded ${key} to ${bucket}`); 34 | return; 35 | } 36 | 37 | if (opts.dir) { 38 | // Handle recursive directory upload 39 | const directoryContent = await readdir(opts.dir, { 40 | recursive: true, 41 | withFileTypes: true, 42 | }); 43 | 44 | const files = directoryContent.reduce((acc: string[], dirent) => { 45 | if (dirent.isFile()) { 46 | acc.push( 47 | dirent.parentPath 48 | ? dirent.parentPath + "/" + dirent.name 49 | : dirent.name 50 | ); 51 | } 52 | return acc; 53 | }, []); 54 | 55 | //TODO: upload more concurrently if file is more than 5 or 10 56 | for (const file of files) { 57 | await client.write(file, Bun.file(file)); 58 | console.log(`✓ Uploaded ${file} to ${bucket}`); 59 | } 60 | 61 | console.log(`Uploaded ${files.length} files to ${bucket}`); 62 | return; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /packages/cli/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bun 2 | 3 | import sade from "sade"; 4 | import { upload } from "./commands/upload"; 5 | import pkg from "./package.json" with { type: "json" }; 6 | 7 | const prog = sade("buntastic"); 8 | 9 | prog 10 | //@ts-ignore 11 | .version(pkg.version) 12 | .example("upload react-site --dir build") 13 | .command("upload ", "Upload files to S3", { default: true }) 14 | .option("--file", "Single file to upload") 15 | .option("--dir", "Directory to upload recursively") 16 | .option("--region", "AWS region") 17 | .option("--endpoint", "S3 endpoint/url") 18 | .option("--access-key-id", "AWS access key ID") 19 | .option("--secret-access-key", "AWS secret access key") 20 | .example("upload react-site --dir build --access-key-id $AWS_ACCESS_KEY_ID --secret-access-key $AWS_SECRET_ACCESS_KEY --endpoint $S3_URL --region $AWS_REGION") 21 | .action(upload); 22 | 23 | prog.parse(process.argv); 24 | -------------------------------------------------------------------------------- /packages/cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pmbanugo/buntastic-cli", 3 | "version": "0.1.1", 4 | "module": "index.ts", 5 | "type": "module", 6 | "description": "A CLI to upload files to S3-compatible storage. Specifically designed for use with Buntastic.", 7 | "bin": { 8 | "buntastic": "index.ts" 9 | }, 10 | "dependencies": { 11 | "sade": "^1.8.1" 12 | }, 13 | "devDependencies": { 14 | "@types/bun": "^1.2.0" 15 | }, 16 | "peerDependencies": { 17 | "typescript": "^5.7.3" 18 | }, 19 | "keywords": [ 20 | "buntastic", 21 | "static-site", 22 | "s3", 23 | "s3-upload", 24 | "bun", 25 | "bun.sh" 26 | ], 27 | "license": "Apache-2.0", 28 | "author": "Peter Mbanugo (https://pmbanugo.me)", 29 | "repository": "https://github.com/pmbanugo/bun-tastic", 30 | "homepage": "https://github.com/pmbanugo/bun-tastic" 31 | } 32 | -------------------------------------------------------------------------------- /packages/cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // Checklist: https://2ality.com/2025/01/tsconfig-json.html 3 | "compilerOptions": { 4 | // Enable latest features 5 | "lib": ["ESNext", "DOM", "DOM.AsyncIterable", "DOM.Iterable"], 6 | "target": "ESNext", 7 | "module": "ESNext", 8 | "moduleDetection": "force", 9 | "jsx": "react-jsx", 10 | "allowJs": true, 11 | 12 | // Bundler mode 13 | "moduleResolution": "bundler", 14 | "allowImportingTsExtensions": true, 15 | "verbatimModuleSyntax": true, 16 | "noEmit": true, 17 | 18 | // Best practices 19 | "strict": true, 20 | "skipLibCheck": true, 21 | "noFallthroughCasesInSwitch": true, 22 | 23 | // Some stricter flags (disabled by default) 24 | "noUnusedLocals": true, 25 | "noUnusedParameters": true, 26 | "noPropertyAccessFromIndexSignature": false 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // Checklist: https://2ality.com/2025/01/tsconfig-json.html 3 | "compilerOptions": { 4 | // Enable latest features 5 | "lib": ["ESNext", "DOM", "DOM.AsyncIterable", "DOM.Iterable"], 6 | "target": "ESNext", 7 | "module": "ESNext", 8 | "moduleDetection": "force", 9 | "jsx": "react-jsx", 10 | "allowJs": true, 11 | 12 | // Bundler mode 13 | "moduleResolution": "bundler", 14 | "allowImportingTsExtensions": true, 15 | "verbatimModuleSyntax": true, 16 | "noEmit": true, 17 | 18 | // Best practices 19 | "strict": true, 20 | "skipLibCheck": true, 21 | "noFallthroughCasesInSwitch": true, 22 | 23 | // Some stricter flags (disabled by default) 24 | "noUnusedLocals": true, 25 | "noUnusedParameters": true, 26 | "noPropertyAccessFromIndexSignature": false 27 | } 28 | } 29 | --------------------------------------------------------------------------------