├── Procfile ├── README.md ├── app.ts ├── misc ├── deploy.sh └── install.sh └── runtime.txt /Procfile: -------------------------------------------------------------------------------- 1 | web: deno run --allow-net=:${PORT} --allow-env=PORT --cached-only app.ts 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # heroku-deno-getting-started 3 | 4 | ## Buildpack 5 | 6 | https://github.com/chibat/heroku-buildpack-deno 7 | 8 | ## Running Locally 9 | Make sure you have [Deno](https://deno.land/) and the [Heroku CLI](https://cli.heroku.com/) installed. 10 | ``` 11 | $ git clone https://github.com/chibat/heroku-deno-getting-started.git 12 | $ cd heroku-deno-getting-started 13 | $ ./app.ts 14 | ``` 15 | Your app should now be running on [localhost:8080](http://localhost:8080/). 16 | 17 | ## Deploying to Heroku 18 | ``` 19 | $ heroku create --buildpack https://github.com/chibat/heroku-buildpack-deno.git 20 | $ git push heroku master 21 | $ heroku open 22 | ``` 23 | 24 | ## more examples 25 | * https://github.com/chibat/heroku-deno-tsconfig-importmap-example (Alosaur) 26 | * https://github.com/chibat/heroku-deno-customized-build-example (Aleph.js) 27 | * https://github.com/chibat/heroku-deno-postgres-example (PostgreSQL) 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S deno run --allow-net=:8080 --allow-env=PORT 2 | 3 | const DEFAULT_PORT = 8080; 4 | const envPort = Deno.env.get("PORT"); 5 | const port = envPort ? Number(envPort) : DEFAULT_PORT; 6 | 7 | if (isNaN(port)) { 8 | console.error("Port is not a number."); 9 | Deno.exit(1); 10 | } 11 | 12 | const listener = Deno.listen({ port }); 13 | console.log("http://localhost:" + port); 14 | for await (const conn of listener) { 15 | (async () => { 16 | const requests = Deno.serveHttp(conn); 17 | for await (const { respondWith } of requests) { 18 | respondWith(new Response("Hello world")); 19 | } 20 | })(); 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /misc/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | heroku login 4 | 5 | git remote |grep -e \s*heroku$ 6 | 7 | if [ "$?" != "0" ] 8 | then 9 | heroku create --buildpack https://github.com/chibat/heroku-buildpack-deno.git 10 | fi 11 | 12 | git push heroku master 13 | 14 | -------------------------------------------------------------------------------- /misc/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | export DENO_INSTALL=$HOME/.deno 4 | export PATH=$DENO_INSTALL/bin:$PATH 5 | curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.0.0 6 | deno --version 7 | 8 | npm install heroku -g 9 | 10 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | v1.13.0 2 | --------------------------------------------------------------------------------