{"id":16159255,"url":"https://github.com/cstrnt/deno-kv-trpcdn","last_synced_at":"2025-04-07T02:27:50.983Z","repository":{"id":174996467,"uuid":"653162781","full_name":"cstrnt/deno-kv-trpcdn","owner":"cstrnt","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-11T09:11:20.000Z","size":181,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T12:10:28.983Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/cstrnt.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":"2023-06-13T14:15:56.000Z","updated_at":"2023-06-13T14:17:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"49baff07-8e8a-4edc-bf36-7828d72757d7","html_url":"https://github.com/cstrnt/deno-kv-trpcdn","commit_stats":null,"previous_names":["cstrnt/deno-kv-trpcdn"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrnt%2Fdeno-kv-trpcdn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrnt%2Fdeno-kv-trpcdn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrnt%2Fdeno-kv-trpcdn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrnt%2Fdeno-kv-trpcdn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cstrnt","download_url":"https://codeload.github.com/cstrnt/deno-kv-trpcdn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247580435,"owners_count":20961610,"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-10-10T01:57:47.480Z","updated_at":"2025-04-07T02:27:50.956Z","avatar_url":"https://github.com/cstrnt.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deno SaaSKit\n\n\u003e Warning: this project is in beta. Design, workflows, and user accounts are\n\u003e subject to change.\n\n[![Discord Chat](https://img.shields.io/discord/684898665143206084?logo=discord\u0026style=social)](https://discord.gg/deno)\n\n[Deno SaaSKit](https://deno.com/saaskit) is an open-sourced, highly performant\ntemplate for building your SaaS quickly and easily.\n\n## Features\n\n- [No build step](https://deno.com/blog/you-dont-need-a-build-step#non-building-with-deno-and-fresh)\n- Deno's built-in [formatter](https://deno.land/manual/tools/formatter),\n  [linter](https://deno.land/manual/tools/linter) and\n  [test runner](https://deno.land/manual/basics/testing) and TypeScript support.\n- Database management and user authentication with\n  [Deno KV](https://deno.com/manual/runtime/kv), which provides zero config\n  durable data storage. _Prefer using Supabase for data storage?\n  [Check out this version of SaaSKit](https://github.com/denoland/saaskit/tree/3b1b14a97eef8859596015b22557d575d3b63c09)._\n- Billing management with [Stripe](https://stripe.com/).\n- [Fresh](https://fresh.deno.dev/) as the web framework and\n  [Tailwind CSS](https://tailwindcss.com/) as the CSS framework.\n\nWant to know where Deno SaaSKit is headed? Check out\n**[our roadmap](https://github.com/denoland/saaskit/issues/60)**.\n\n## Getting Started Locally\n\n### Prerequisites\n\n- [Deno](https://deno.com/manual/getting_started/installation)\n- [Git](https://github.com/git-guides/install-git)\n- [A free Stripe account](https://stripe.com)\n- [Stripe CLI](https://stripe.com/docs/stripe-cli#install)\n\n### Setup the repo\n\n1. Clone the repo:\n\n   ```bash\n   git clone https://github.com/denoland/saaskit.git\n   cd saaskit\n   ```\n\n2. Create a `.env` file to store environmental variables:\n\n   ```\n   cp .example.env .env\n   ```\n\n### Auth (OAuth)\n\n1. [Register a new GitHub OAuth application](https://github.com/settings/applications/new)\n   with the following values:\n\n   - `Application name` = a name of your own choosing\n   - `Homepage URL` = `http://localhost:8000`\n   - `Authorization callback URL` = `http://localhost:8000/callback`\n\n2. Once registered, copy the `Client ID` value to the `GITHUB_CLIENT_ID` value\n   in your `.env` file.\n3. Click `Generate a new client secret` and copy the resulting client secret to\n   the `GITHUB_CLIENT_SECRET` environment variable in your `.env` file.\n\n### Payments and Subscriptions (Stripe)\n\n1. Copy your Stripe secret key as `STRIPE_SECRET_KEY` into your `.env` file. We\n   recommend using the test key for your development environment.\n2. Run `deno task init:stripe` and follow the instructions. This automatically\n   creates your \"Premium tier\" product and configures the Stripe customer\n   portal.\n   \u003e Note: go to [tools/init_stripe.ts](tools/init_stripe.ts) if you'd like to\n   \u003e learn more about how the `init:stripe` task works.\n3. Listen locally to Stripe events:\n   ```\n   stripe listen --forward-to localhost:8000/api/stripe-webhooks --events=customer.subscription.created,customer.subscription.deleted\n   ```\n4. Copy the webhook signing secret to [.env](.env) as `STRIPE_WEBHOOK_SECRET`.\n\n\u003e Note: You can use\n\u003e [Stripe's test credit cards](https://stripe.com/docs/testing) to make test\n\u003e payments while in Stripe's test mode.\n\n### Running the Server\n\nFinally, start the server by running:\n\n```\ndeno task start\n```\n\nGo to [http://localhost:8000](http://localhost:8000) to begin playing with your\nnew SaaS app.\n\n### Bootstrapping your local Database (Optional)\n\nIf the home page is feeling a little empty, run\n\n```\ndeno task db:seed\n```\n\nOn execution, this script will fetch 20 (customizable) of the top HN posts using\nthe [HackerNews API](https://github.com/HackerNews/API) to populate your home\npage.\n\nTo see all the values in your local Deno KV database, run\n\n```\ndeno task db:dump\n```\n\nAnd all kv pairs will be logged to stdout\n\nTo reset your Deno KV database, run\n\n```\ndeno task db:reset\n```\n\nSince this operation is not recoverable, you will be prompted to confirm\ndeletion before proceeding.\n\n## Customization\n\n### Global Constants\n\nThe [utils/constants.ts](utils/constants.ts) file includes global values used\nacross various aspects of the codebase. Update these values according to your\nneeds.\n\n### Blog\n\nTo create a new blog post, create a Markdown (`.md`) file within\n[`/data/posts/`](data/posts) with the filename as the slug. E.g.\n`/data/blog/hello-there.md` will correspond to the `/blog/hello-there` route.\nSee [`/data/posts/`](data/posts) for examples.\n\nPost properties are to be added to the starting Front Matter section of the\nMarkdown file. See the `Post` interface in [`/utils/posts.ts`](utils/posts.ts)\nfor a full list of properties and their types.\n\n### Themes\n\nYou can customize theme options such as spacing, color, etc. By default, Deno\nSaaSKit comes with `primary` and `secondary` colors predefined within\n`twind.config.ts`. Change these values to match your desired color scheme.\n\n## Deploying to Production\n\nThis section assumes that a\n[local development environment](#getting-started-locally) has been set up.\n\n### Authentication (OAuth)\n\n1. [Change your OAuth app settings](https://github.com/settings/developers) to\n   the following:\n\n- `Homepage URL` = `https://{{ YOUR DOMAIN }}`\n- `Authorization callback URL` = `http://{{ YOUR DOMAIN }}/callback`\n\n### Payments (Stripe)\n\nIn order to use Stripe in production, you'll have to\n[activate your Stripe account](https://stripe.com/docs/account/activate).\n\nOnce your Stripe account is activated, simply grab the production version of the\nStripe Secret Key. That will be the value of `STRIPE_SECRET_KEY` in prod.\n\n### Automate Stripe Subscription Updates via Webhooks\n\nKeep your user's customer information up-to-date with billing changes by\n[registering a webhook endpoint in Stripe](https://stripe.com/docs/development/dashboard/register-webhook).\n\n- Endpoint URL: `https://{{ YOUR DOMAIN }}/api/stripe-webhooks`\n- Listen to `Events on your account`\n- Select `customer.subscription.created` and `customer.subscription.deleted`\n\n### Stripe Production Environmental Variables\n\n- `STRIPE_SECRET_KEY`: Dashboard Home (Right Side of Page) -\u003e Secret Key (only\n  revealed once)\n- `STRIPE_WEBHOOK_SECRET`: Dashboard Home -\u003e Developers (right side of page) -\u003e\n  Create webhook -\u003e Click Add Endpoint\n  - After Creation, redirected to new webhook page -\u003e Signing Secret -\u003e Reveal\n- `STRIPE_PREMIUM_PLAN_PRICE_ID`: Dashboard -\u003e Products -\u003e Premium Tier -\u003e\n  Pricing/API ID\n\n### Stripe Customer Portal Branding\n\n[Set up your branding on Stripe](https://dashboard.stripe.com/settings/branding),\nas the user will be taken to Stripe's checkout page when they upgrade to a\nsubscription.\n\n## Using Docker to Deploy to any VPS\n\n[Docker](https://docker.com) makes it easy to deploy and run your Deno app to\nany virtual private server (VPS). This section will show you how to do that with\nAWS Lightsail and Digital Ocean.\n\n### Setting up Docker\n\n1. [Install Docker](https://docker.com) on your machine, which should also\n   install\n   [the `docker` CLI](https://docs.docker.com/engine/reference/commandline/cli/).\n\n2. Create an account on [Docker Hub](https://hub.docker.com), a registry for\n   Docker container images.\n\n3. Create a `Dockerfile` in the root of your repo:\n\n   ```docker\n   FROM denoland/deno:1.32.4\n   EXPOSE 8000\n   WORKDIR /app\n   ADD . /app\n\n   # Add dependencies to the container's Deno cache\n   RUN deno cache main.ts --import-map=import_map.json\n   CMD [\"run\", \"--allow-run\", \"--allow-write\", \"--allow-read\", \"--allow-env\", \"--allow-net\", \"main.ts\"]\n   ```\n\n4. Create a `.dockerignore` file in the root folder of your repo to make sure\n   certain files are not deployed to the docker container:\n\n   ```dockerignore\n   README.md\n   .example.env\n   .vscode/\n   .github/\n   ```\n\n5. A `docker-compose.yml` file will be needed to run the docker file on a VPS.\n   Here’s what that file in your repo's root folder will look like:\n\n   ```yml\n   version: '3'\n\n   services:\n     web:\n       build: .\n       container_name: deno-sasskit\n       image: deno-image\n     environment:\n        - DENO_DEPLOYMENT_ID=${DENO_DEPLOYMENT_ID}\n        - GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}\n        - GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET}\n        - STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}\n        - STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET}\n        - STRIPE_PREMIUM_PLAN_PRICE_ID=${STRIPE_PREMIUM_PLAN_PRICE_ID}\n     ports:\n         - \"8000:8000\"\n   ```\n\nThe values of the environmental variables are pulled from the `.env` file.\n\nThe `DENO_DEPLOYMENT_ID` variable is needed for Docker deployment of a Deno\nFresh app for caching to work properly. Its value needs to be a unique id tied\nto the deployment. We recommend using the SHA1 commit hash, which can be\nobtained from the following command run in the repo's root folder:\n\n```sh\n# get the SHA1 commit hash of the current branch\ngit rev-parse HEAD\n```\n\n### Automatic Deployment with Deno Deploy\n\nThese steps show you how to deploy your SaaS app close to your users at the edge\nwith [Deno Deploy](https://deno.com/deploy).\n\n1. Clone this repository for your SaaSKit project.\n\n2. Sign into [Deno Deploy](https://dash.deno.com) with your GitHub account.\n\n3. Select your GitHub organization or user, repository, and branch\n\n4. Select \"Automatic\" deployment mode and `main.ts` as the entry point\n\n5. Click \"Link\", which will start the deployment.\n\n6. Once the deployment is complete, click on \"Settings\" and add the production\n   environmental variables, then hit \"Save\"\n\nYou should be able to visit your newly deployed SaaS.\n\n### Deno Deploy via GitHub Action\n\nYou can also choose to deploy to\n[Deno Deploy via a GitHub Action](https://github.com/denoland/deployctl/blob/main/action/README.md),\nwhich offers more flexibility. For instance, with the GitHub Action, you could:\n\n- Add a build step\n- Run `deno lint` to lint your code\n- Run `deno test` to run automated unit tests\n\n1. Create\n   [a new, empty project from the Deno Deploy dashboard](https://dash.deno.com/new).\n   Set a name for your project.\n\n2. Add the GitHub Action.\n\n   [GitHub Actions](https://docs.github.com/en/actions) are configured using a\n   `.yml` file placed in the `.github/workflows` folder of your repo. Here's an\n   example `.yml` file to deploy to Deno Deploy. Be sure to update the\n   `YOUR_DENO_DEPLOY_PROJECT_NAME` with one that you've set in Deno Deploy.\n\n   ```yml\n   # Github action to deploy this project to Deno Deploy\n   name: Deploy\n   on: [push]\n\n   jobs:\n     deploy:\n       name: Deploy\n       runs-on: ubuntu-latest\n       permissions:\n         id-token: write  # Needed for auth with Deno Deploy\n         contents: read  # Needed to clone the repository\n\n       steps:\n         - name: Clone repository\n           uses: actions/checkout@v3\n\n         - name: Install Deno\n           uses: denoland/setup-deno@main\n           # If you need to install a specific Deno version\n           # with:\n           #   deno-version: 1.32.4\n\n   ## You would put your building, linting, testing and other CI/CD steps here\n\n   ## Finally, deploy\n         - name: Upload to Deno Deploy\n           uses: denoland/deployctl@v1\n           with:\n             project: YOUR_DENO_DEPLOY_PROJECT_NAME\n             entrypoint: main.ts\n             # root: dist\n             import-map: import_map.json\n             exclude: .git/** .gitignore .vscode/** .github/** README.md .env .example.env\n   ```\n\n3. Commit and push your code to GitHub. This should trigger the GitHub Action.\n   When the action successfully completes, your app should be available on Deno\n   Deploy.\n\n### Deploying to Amazon Lightsail with Docker\n\nIn order to deploy your Docker image to Amazon Lightsail you need to create an\nAWS account if you don’t already have one.\n\n1. The deployment process starts with a local Docker image build which requires\n   that the `Dockerfile` and `docker-compose.yml` have beed created\n   [as above](#setting-up-docker):\n\n   ```sh\n   docker compose -f docker-compose.yml build\n   ```\n\n2. Tag your image locally using the following command:\n\n   ```sh\n   docker tag deno-image {{ username }}/deno-saaskit-aws\n   ```\n\n   The name `deno-image` comes from your `docker-compose.yml` file.\n\n3. The tagged image needs to be registered on\n   [Docker Hub](https://hub.docker.com). In order to do that, sign into your Hub\n   account (or create one if you don’t have one).\n\n4. Push the tagged image to Docker Hub. We have chosen the name\n   `deno-saaskit-aws` which you can change. Substitute `{{username}}` with your\n   Docker Hub username.\n\n   ```sh\n   docker push {{ username }}/deno-saaskit-aws\n   ```\n\n   You should then be able to see your image on Docker Hub where it can be\n   picked up by the AWS container service.\n\n5. Go to the\n   [AWS LIghtsail Create a Container Service landing page](https://lightsail.aws.amazon.com/ls/webapp/create/container-service).\n   On that page you can choose a server location and service capacity or keep\n   the defaults.\n\n   - Click on “Setup deployment” and choose “Specify a custom deployment” which\n     will result in the display of a form. Here’s what you need to fill out:\n\n     - _Container name_: Give it a name of your choosing.\n     - _Image_: Use the Docker Hub name {{username}}/deno-saaskit-aws.\n     - _Open Ports_: Click “Add open ports” and then enter “8000” as the port.\n     - _Environmental Variables_: Enter the name and values of all production\n       environmental variables from `.env`.\n     - _Public Endpoint_: Select the container name you just entered.\n\n   Under “Identify your service”, enter a container service name of your\n   choosing. It will become part of the app's domain.\n\n6. Click the “Create Container Service” button. It will take some time for the\n   deployment to complete. You will see a \"Deployed” message when it is\n   finished.\n\nAfter the deployment is complete, click on the public address link and you'll\nsee your app running in the browser.\n\n### Deploying to Digital Ocean with Docker\n\nTo deploy your image to Digital Ocean, you will need A\n[Digital Ocean account](https://www.digitalocean.com/) and the\n[`doctl` CLI](https://docs.digitalocean.com/reference/doctl/how-to/install/)\ninstalled and validated locally.\n\n1. Build the Docker image locally and tag it for a Digital Ocean Container\n   Registry. This requires that you have created `Dockerfile` and\n   `docker-compose.yml` files [as instructed above](#setting-up-docker)\n\n   ```sh\n   # Local Docker build\n   docker compose -f docker-compose.yml build\n   ```\n\n   ```sh\n   # Tag for DO container registry (separate from Docker Hub)\n   docker tag deno-image registry.digitalocean.com/deno-saaskit/deno-image:new\n   ```\n\n2. Push your tagged image to your DO container registry.\n\n   - [Create an API token with `doctl`](https://docs.digitalocean.com/reference/doctl/how-to/install/#step-2-create-an-api-token)\n     and\n     [validate that you can authenticate with the CLI](https://docs.digitalocean.com/reference/doctl/how-to/install/#step-4-validate-that-doctl-is-working).\n\n   - Login using `doctl` and the API token you just created:\n\n   ```sh\n   doctl registry login -t {{ API Access Token }}\n   ```\n\n   - Create a Digital Ocean Container Registry named `deno-saaskit`:\n\n   ```sh\n   doctl registry create deno-saaskit\n   ```\n\n   Alternatively, you can\n   [create the container registry online](https://docs.digitalocean.com/products/container-registry/quickstart/).\n\n   - Push the image to Digital Ocean’s registry (make sure you are logged in\n     using `doctl registry login`).\n\n   ```sh\n   docker push registry.digitalocean.com/deno-saaskit/deno-image:new\n   ```\n\n   You should now be able to see your image in the\n   [DO Container Registry](https://cloud.digitalocean.com/registry).\n\n3. Once the `deno-image` has been pushed to the Digital Ocean registry we can\n   run it in a\n   [Digital Ocean Droplet](https://www.digitalocean.com/products/droplets). Go\n   to your\n   [Digital Ocean project page](https://cloud.digitalocean.com/projects/) and\n   click the 'Create' button and select 'Droplets'.\n\n4. When the droplet is created, use the `console` link on your droplet page to\n   SSH to the droplet VM or\n   [use SSH locally](https://docs.digitalocean.com/products/droplets/how-to/connect-with-ssh/)\n   run this command:\n\n   ```sh\n   docker run -d --restart always -it -p 8000:8000 --name deno-image registry.digitalocean.com/deno-on-digital-ocean/deno-image:new\n   ```\n\nThe URL will be visible once the command completes. Use the droplet's IP address\nwith port `8000` to browse to your application deployed on Digital Ocean.\n\n## Contributing\n\nWhen submitting a pull request, please follow the\n[Deno Style Guide](https://deno.land/manual/references/contributing/style_guide).\n\nBefore submitting, run the following to check the formatting, linting, licenses,\nand types and run tests in one hit:\n\n```\ndeno task ok\n```\n\n## Goals and Philosophy\n\nFor the user, the website should be fast, secure and have a design with clear\nintent. Additionally, the HTML should be well-structured and indexable by search\nengines. The defining metrics for these goals are:\n\n- A perfect [PageSpeed Insights](https://pagespeed.web.dev/) score.\n- Fully valid HTML, as measured by\n  [W3C's Markup Validation Service](https://validator.w3.org/).\n\nFor the developer, the codebase should minimize the steps and amount of time\nrequired to get up and running. From there, customization and extension of the\nweb app should be simple. The characteristics of a well-written codebase also\napply, such as:\n\n- Easy to understand\n- Modular functionality\n- Clearly defined behavior with validation through tests\n\n## Community and Resources\n\nJoin\n[the `#saaskit` channel in Deno's Discord](https://discord.com/channels/684898665143206084/1085986084653109438)\nto meet other SaaSKit developers, ask questions, and get unblocked.\n\nHere's a list of articles, how to guides, and videos about SaaSKit:\n\n- [Announcing Deno SaaSKit](https://deno.com/blog/announcing-deno-saaskit)\n- [Getting Started with SaaSKit (video walkthrough)](https://www.youtube.com/watch?v=1GYs3NbVCfE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcstrnt%2Fdeno-kv-trpcdn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcstrnt%2Fdeno-kv-trpcdn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcstrnt%2Fdeno-kv-trpcdn/lists"}