├── slack ├── demo.png ├── install.png ├── readme.md ├── mod.ts └── cities.ts ├── discord ├── demo.png ├── readme.md └── mod.ts ├── telegram ├── demo.png ├── README.md └── mod.ts ├── fetch ├── README.md ├── post.js └── get.js ├── yaus ├── schema.gql ├── readme.md └── mod.tsx ├── Makefile ├── issues ├── mod.js ├── pages │ ├── 404.jsx │ ├── home.jsx │ └── api │ │ └── issues.js ├── components │ ├── layout.jsx │ ├── search.jsx │ └── card.jsx ├── readme.md └── data │ └── repositories.js ├── README.md ├── .github └── workflows │ └── ci.yml ├── LICENSE ├── post_request ├── readme.md └── mod.js └── json_html ├── README.md └── mod.js /slack/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denoland/deploy_examples/main/slack/demo.png -------------------------------------------------------------------------------- /discord/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denoland/deploy_examples/main/discord/demo.png -------------------------------------------------------------------------------- /slack/install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denoland/deploy_examples/main/slack/install.png -------------------------------------------------------------------------------- /telegram/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denoland/deploy_examples/main/telegram/demo.png -------------------------------------------------------------------------------- /fetch/README.md: -------------------------------------------------------------------------------- 1 | # fetch() examples 2 | 3 | The examples here demonstrate how to make fetch() requests. 4 | 5 | - [`GET`](get.js) - makes a GET request to GitHub API endpoint. 6 | - [`POST`](post.js) - makes a POST request to https://post.deno.dev (echoes the 7 | request body back). 8 | -------------------------------------------------------------------------------- /discord/readme.md: -------------------------------------------------------------------------------- 1 | # Discord Slash Command 2 | 3 | A simple Discord Slash Command. 4 | 5 | demo of discord slash command 6 | 7 | Read [the tutorial](https://deno.com/deploy/docs/tutorial-discord-slash) to 8 | learn how to create and deploy a Discord Slash Command. 9 | -------------------------------------------------------------------------------- /yaus/schema.gql: -------------------------------------------------------------------------------- 1 | # An object containing the long url and corresponding short code. 2 | type Link { 3 | url: String! @unique 4 | code: String! @unique 5 | } 6 | 7 | # Queries to fetch code by url and vice versa. 8 | type Query { 9 | findCodeByUrl(url: String!): Link 10 | findUrlByCode(code: String!): Link 11 | } 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Check TypeScript types. 2 | check: 3 | deno cache fetch/get.js 4 | deno cache fetch/post.js 5 | deno cache post_request/mod.js 6 | deno cache json_html/mod.js 7 | deno cache issues/mod.js 8 | deno cache discord/mod.ts 9 | deno cache slack/mod.ts 10 | deno cache yaus/mod.tsx 11 | deno cache telegram/mod.ts 12 | -------------------------------------------------------------------------------- /issues/mod.js: -------------------------------------------------------------------------------- 1 | import { serve } from "https://deno.land/x/sift@0.4.2/mod.ts"; 2 | import homePage from "./pages/home.jsx"; 3 | import notFoundPage from "./pages/404.jsx"; 4 | import issuesEndpoint from "./pages/api/issues.js"; 5 | 6 | serve({ 7 | "/": homePage, 8 | "/api/issues": issuesEndpoint, 9 | 404: notFoundPage, 10 | }); 11 | -------------------------------------------------------------------------------- /issues/pages/404.jsx: -------------------------------------------------------------------------------- 1 | import { h } from "https://deno.land/x/sift@0.4.2/mod.ts"; 2 | import Layout from "../components/layout.jsx"; 3 | 4 | export default function notFoundPage(request) { 5 | return ( 6 | 7 |
8 |

Page not found

9 |
10 |
11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /issues/components/layout.jsx: -------------------------------------------------------------------------------- 1 | import { h } from "https://deno.land/x/sift@0.4.2/mod.ts"; 2 | 3 | export default function Layout({ children }) { 4 | return ( 5 | 6 | 7 | 8 | 12 | 16 | 17 | 18 | {children} 19 | 20 | 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deno Deploy Examples 2 | 3 | This repository contains a list of examples for Deno Deploy. 4 | 5 | - [fetch](fetch) - Make outbound requests using the `fetch()` API. 6 | - [json_html](json_html) - Respond to requests with JSON or HTML. 7 | - [post_request](post_request) - Handle POST requests. 8 | - [slack](slack) - A Slack Slash Command example. 9 | - [discord](discord) - A Discord Slash Command example. 10 | - [yaus](yaus) - A URL shortener built on top of Deno Deploy and FaunaDB. 11 | - [issues](issues) - A server rendered (using JSX) website that displays issues 12 | with most comments of a GitHub repository. 13 | - [telegram](telegram) - A Telegram Bot Command example. 14 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | on: 3 | push: 4 | branches: [main] 5 | pull_request: 6 | branches: [main] 7 | 8 | jobs: 9 | lint: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Clone repository 13 | uses: actions/checkout@v3 14 | with: 15 | submodules: false 16 | persist-credentials: false 17 | 18 | - name: Install Deno 19 | run: |- 20 | curl -fsSL https://deno.land/x/install/install.sh | sh 21 | echo "$HOME/.deno/bin" >> $GITHUB_PATH 22 | 23 | - name: Format 24 | run: deno fmt --check 25 | 26 | - name: Lint 27 | run: deno lint --unstable 28 | 29 | - name: Type Check 30 | run: make check 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Deno Land Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /issues/pages/home.jsx: -------------------------------------------------------------------------------- 1 | import { h } from "https://deno.land/x/sift@0.4.2/mod.ts"; 2 | import Card from "../components/card.jsx"; 3 | import Layout from "../components/layout.jsx"; 4 | import Search from "../components/search.jsx"; 5 | import { getIssues } from "./api/issues.js"; 6 | 7 | export default async function homePage(request) { 8 | const { searchParams } = new URL(request.url); 9 | const repo = searchParams.get("repository"); 10 | const { repository, issues, code, message } = await getIssues(repo); 11 | 12 | return ( 13 | 14 |
15 | Most Discussed Issues 16 | 17 | {issues && ( 18 |
19 | The most discussed issues of{" "} 20 | 24 | {repository} 25 | 26 |
27 | {issues.map((issue) => )} 28 |
29 |
30 | )} 31 | {code &&
{message}
} 32 |
33 |
34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /post_request/readme.md: -------------------------------------------------------------------------------- 1 | # Handle a POST Request 2 | 3 | This example demonstrates how to handle POST requests in Deno Deploy. 4 | 5 | [![Deploy this example](https://deno.com/deno-deploy-button.svg)](https://dash.deno.com/new?url=https://raw.githubusercontent.com/denoland/deploy_examples/main/post_request/mod.js) 6 | 7 | - [Try Live Version](#try-live-version) 8 | - [Run offline](#run-offline) 9 | 10 | ## Try Live Version 11 | 12 | The example is deployed at https://post.deno.dev for demo. 13 | 14 | A POST request with JSON body: 15 | 16 | ```sh 17 | curl -X POST \ 18 | -H 'content-type: application/json' \ 19 | -d '{ "name": "Deno" }' https://post.deno.dev 20 | ``` 21 | 22 | Response: 23 | 24 | ```json 25 | { 26 | "json": { 27 | "name": "Deno" 28 | } 29 | } 30 | ``` 31 | 32 | A POST request with form data: 33 | 34 | ```sh 35 | curl -X POST -F 'name=Deno' https://post.deno.dev 36 | ``` 37 | 38 | Response: 39 | 40 | ```json 41 | { 42 | "form": { 43 | "name": "Deno" 44 | } 45 | } 46 | ``` 47 | 48 | ## Run Offline 49 | 50 | You can run the example program on your machine using 51 | [`deno`](https://github.com/denoland/deno): 52 | 53 | ```sh 54 | deno run https://raw.githubusercontent.com/denoland/deploy_examples/main/post_request/mod.js 55 | ``` 56 | -------------------------------------------------------------------------------- /issues/components/search.jsx: -------------------------------------------------------------------------------- 1 | import { h } from "https://deno.land/x/sift@0.4.2/mod.ts"; 2 | 3 | /** Validate if the form value follows the appropriate 4 | * structure (/). */ 5 | function validateForm() { 6 | // deno-lint-ignore no-undef 7 | const repository = document.forms["search"]["repository"].value; 8 | if (repository.split("/").length !== 2) { 9 | alert( 10 | `Input should be in the form of 'owner/repository'. No forward slashes at the beginning or end.`, 11 | ); 12 | return false; 13 | } 14 | return true; 15 | } 16 | 17 | export default function Search() { 18 | return ( 19 |
20 |