Skip to content

Commit

Permalink
Merge pull request #46 from denoland/polish_9_14
Browse files Browse the repository at this point in the history
Polish updates for 9/14
  • Loading branch information
kwhinnery authored Sep 15, 2023
2 parents b1f4445 + e1afa3b commit 4077356
Show file tree
Hide file tree
Showing 51 changed files with 444 additions and 167 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ import Replacement from "@site/src/components/Replacement";
The current CLI version is **<Replacement for="CLI_VERSION"/>**.
```

If you are writing inline JSX, you can also use the replacements object directly
like so:

```mdx
import { replacements } from "@site/src/components/Replacement";

<p>
The current CLI version is <code>{ replacements.CLI_VERSION }</code>.
</p>
```

## Server-side code and redirects

The Deno code that serves the site in production is in the `src-deno` folder.
Expand Down
2 changes: 1 addition & 1 deletion deploy/api/runtime-broadcast-channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ running instances in different regions and another to fetch all messages from an
instance.

```ts
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";

const messages = [];
// Create a new broadcast channel named earth.
Expand Down
15 changes: 6 additions & 9 deletions deploy/api/runtime-fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@ allows you to make outbound HTTP requests in Deno Deploy. It is a web standard
and has the following interfaces:

- `fetch()` - The method that allows you to make outbound HTTP requests
- [`Request`](./runtime-request) - represents a request resource of
fetch()
- [`Response`](./runtime-response) - represents a response resource of
fetch()
- [`Request`](./runtime-request) - represents a request resource of fetch()
- [`Response`](./runtime-response) - represents a response resource of fetch()
- [`Headers`](./runtime-headers) - represents HTTP Headers of requests and
responses.

This page shows usage for the fetch() method. You can click above on the other
interfaces to learn more about them.

Fetch also supports fetching from file URLs to retrieve static files. For more
info on static files, see the
[filesystem API documentation](./runtime-fs).
info on static files, see the [filesystem API documentation](./runtime-fs).

## `fetch()`

Expand All @@ -33,8 +30,8 @@ function fetch(

#### Parameters

| name | type | optional | description |
| -------- | ------------------------------------------------------------------- | -------- | ------------------------------------------------------------------ |
| name | type | optional | description |
| -------- | ------------------------------------------------------------- | -------- | ------------------------------------------------------------------ |
| resource | [`Request`](./runtime-request) <br/> [`USVString`][usvstring] | `false` | The resource can either be a request object or a URL string. |
| init | [`RequestInit`](./runtime-request#requestinit) | `true` | The init object lets you apply optional parameters to the request. |

Expand All @@ -47,7 +44,7 @@ The Deno Deploy script below makes a `fetch()` request to the GitHub API for
each incoming request, and then returns that response from the handler function.

```js
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";

async function handler(req: Request): Promise<Response> {
const resp = await fetch("https://api.github.com/users/denoland", {
Expand Down
25 changes: 12 additions & 13 deletions deploy/api/runtime-fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ This example lists the contents of a directory and returns this list as a JSON
object in the response body.

```js
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
async function handler(_req) {
// List the posts in the `blog` directory located at the root
Expand Down Expand Up @@ -90,7 +90,7 @@ This example reads the contents of a file into memory as a byte array, then
returns it as the response body.

```js
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
async function handler(_req) {
// Let's read the README.md file available at the root
Expand All @@ -116,10 +116,9 @@ serve(handler);

> Note: to use this feature, you must link a GitHub repository to your project.
Deno Deploy supports the `Deno.readFile`
API to read static assets from the file system. This is useful for serving
static assets such as images, stylesheets, and JavaScript files. This guide
demonstrates how to use this feature.
Deno Deploy supports the `Deno.readFile` API to read static assets from the file
system. This is useful for serving static assets such as images, stylesheets,
and JavaScript files. This guide demonstrates how to use this feature.

Imagine the following file structure on a GitHub repository:

Expand All @@ -131,7 +130,7 @@ Imagine the following file structure on a GitHub repository:
The contents of `mod.ts`:

```ts
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";

async function handleRequest(request: Request): Promise<Response> {
const { pathname } = new URL(request.url);
Expand Down Expand Up @@ -193,7 +192,7 @@ This example reads a text file into memory and returns the contents as the
response body.

```js
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
async function handler(_req) {
const readme = await Deno.readTextFile("./README.md");
Expand Down Expand Up @@ -226,8 +225,8 @@ The path can be a relative or absolute. It can also be a `file:` URL.
This example opens a file, and then streams the content as the response body.

```js
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { readableStreamFromReader } from "https://deno.land/std@0.140.0/streams/conversion.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
import { readableStreamFromReader } from "https://deno.land/std@$STD_VERSION/streams/conversion.ts";
async function handler(_req) {
// Open the README.md file available at the root of the repository.
Expand Down Expand Up @@ -305,7 +304,7 @@ This example gets the size of a file, and returns the result as the response
body.

```js
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
async function handler(_req) {
// Get file info of the README.md at the root of the repository.
Expand Down Expand Up @@ -373,7 +372,7 @@ This example calls `Deno.realPath()` to get the absolute path of a file in the
root of the repository. The result is returned as the response body.

```ts
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
async function handler(_req) {
const path = await Deno.realPath("./README.md");
Expand Down Expand Up @@ -403,7 +402,7 @@ This example calls `Deno.readLink()` to get the absolute path of a file in the
root of the repository. The result is returned as the response body.

```ts
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
async function handler(_req) {
const path = await Deno.readLink("./my_symlink");
Expand Down
4 changes: 2 additions & 2 deletions deploy/api/runtime-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The return type is a `Request` instance.
| [`body`][body] | [`ReadableStream`][readablestream] | The getter exposes a `ReadableStream` of the body contents. |
| [`bodyUsed`][bodyused] | `boolean` | Indicates whether the body content is read. |
| [`url`][url] | `USVString` | The URL of the request. |
| [`headers`][headers] | [`Headers`](runtime-headers) | The headers associated with the request. |
| [`headers`][headers] | [`Headers`](runtime-headers) | The headers associated with the request. |
| [`integrity`][integrity] | `string` | The crypotographic hash of the request's body. |
| [`method`][method] | `string` | The request's method (`POST`, `GET`, etc). |
| [`mode`][mode] | `string` | Indicates the mode of the request (e.g. `cors` ). |
Expand All @@ -74,7 +74,7 @@ All the above properties are read only.
## Example

```ts
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";

function handler(_req) {
// Create a post request
Expand Down
2 changes: 1 addition & 1 deletion deploy/api/runtime-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The return type is a `Response` instance.
## Example

```ts
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";

function handler(_req) {
// Create a response with html as its body.
Expand Down
4 changes: 2 additions & 2 deletions deploy/api/runtime-sockets.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Deno.connect(options: ConnectOptions): Promise<Conn>
### Example

```js
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
async function handler(_req) {
// Make a TCP connection to example.com
Expand Down Expand Up @@ -65,7 +65,7 @@ function Deno.connectTls(options: ConnectTlsOptions): Promise<Conn>
### Example

```js
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
async function handler(_req) {
// Make a TLS connection to example.com
Expand Down
2 changes: 1 addition & 1 deletion deploy/manual/ci_github.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ process by leveraging the `deployctl` [Github action][deploy-action]:
uses: denoland/deployctl@v1
with:
project: my-project
entrypoint: https://deno.land/std/http/file_server.ts
entrypoint: https://deno.land/std@$STD_VERSION/http/file_server.ts
root: dist
```

Expand Down
2 changes: 1 addition & 1 deletion deploy/manual/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,6 @@ centers around the world, ready to handle large volumes of traffic.
## Next Steps

Now that you've created your first project, you can
[check out the kids of apps](./use-cases.md) you can run on Deploy. You could
[check out the kinds of apps](./use-cases.md) you can run on Deploy. You could
also skip right to [setting up your own custom domain](./custom-domains.md).
We're so excited to see what you'll ship with Deploy!
2 changes: 1 addition & 1 deletion deploy/manual/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ On the next page, copy and paste the code below into the editor. It is an HTTP
server that proxies all requests to https://example.com.

```ts
import { serve } from "https://deno.land/std/http/mod.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/mod.ts";
async function reqHandler(req: Request) {
const reqPath = new URL(req.url).pathname;
return await fetch("https://example.com" + reqPath, { headers: req.headers });
Expand Down
2 changes: 1 addition & 1 deletion deploy/tutorials/simple-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This tutorial will cover how to deploy a simple API on Deno Deploy.
```js
// simple_api.js

import { serve } from "https://deno.land/std@0.155.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";

serve((req: Request) => new Response("Hello World"));
```
Expand Down
2 changes: 1 addition & 1 deletion deploy/tutorials/static-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You have now a html page that says "Hello" and has a logo.
To deploy this repo on Deno Deploy, from the `static-site` repository, run:

```
deployctl deploy --project=careful-goat-90 https://deno.land/std@0.171.0/http/file_server.ts
deployctl deploy --project=careful-goat-90 https://deno.land/std@$STD_VERSION/http/file_server.ts
```

To give a little more explanation of these commands: Because this is a static
Expand Down
8 changes: 4 additions & 4 deletions deploy/tutorials/tutorial-http-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Deploy lets you listen for incoming HTTP requests using the same
level though, so instead of using this API directly we'll use the high level
HTTP API exposed by [`std/http`][std-http].

This API revolves around the
[`serve`](https://deno.land/std@0.140.0/http/server.ts) function.
This API revolves around the [`serve`](https://deno.land/std/http/server.ts)
function.

```js
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";

serve((_req) => {/* .. */});
```
Expand All @@ -34,7 +34,7 @@ underlying connection, such as the origin IP address. You must return a
Let's use this information to finish our hello world script:

```js
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";

serve((_req) => {
return new Response("Hello World!", {
Expand Down
4 changes: 2 additions & 2 deletions deploy/tutorials/tutorial-postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ left navigation menu, and press "Open Playground". Let's start by the `std/http`
module so we can start serving HTTP requests:

```ts
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";

serve(async (req) => {
return new Response("Not Found", { status: 404 });
Expand All @@ -105,7 +105,7 @@ Next, let's import the Postgres module, read the connection string from the
environment variables, and create a connection pool.

```ts
import { serve } from "https://deno.land/std@0.140.0/http/server.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
import * as postgres from "https://deno.land/x/postgres@v0.14.0/mod.ts";

// Get the connection string from the environment variable "DATABASE_URL"
Expand Down
7 changes: 4 additions & 3 deletions deploy/tutorials/vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Since there is a build step here, you will need to use the Github Actions mode.
uses: denoland/deployctl@v1
with:
project: "<project-name>"
entrypoint: https://deno.land/std/http/file_server.ts
entrypoint: https://deno.land/std@$STD_VERSION/http/file_server.ts
root: dist
```

Expand All @@ -109,7 +109,8 @@ Since there is a build step here, you will need to use the Github Actions mode.
- running `deno task build`

You will also have to set the entrypoint file to
`https://deno.land/std/http/file_server.ts`, and the root to `/dist`.
`https://deno.land/std@$STD_VERSION/http/file_server.ts`, and the root to
`/dist`.

Note that this is not a file that exists in the Vite repo itself. Instead, it
is an external program. When run, this program uploads all the static asset
Expand All @@ -127,5 +128,5 @@ Deploy.

```
cd /dist
deployctl deploy --project=<project-name> https://deno.land/std@0.171.0/http/file_server.ts
deployctl deploy --project=<project-name> https://deno.land/std@$STD_VERSION/http/file_server.ts
```
6 changes: 6 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const config = {
path: "deploy",
routeBasePath: "/deploy",
sidebarPath: require.resolve("./sidebars/deploy.js"),
remarkPlugins: [
findReplace,
],
},
],
[
Expand All @@ -64,6 +67,9 @@ const config = {
path: "kv",
routeBasePath: "/kv",
sidebarPath: require.resolve("./sidebars/kv.js"),
remarkPlugins: [
findReplace,
],
},
],
// Enables our custom pages in "src" to use Tailwind classes
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/advanced/continuous_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ To demonstrate, let's say you have a project that uses the logger from
`deno.land/std`:

```ts
import * as log from "https://deno.land/std/log/mod.ts";
import * as log from "https://deno.land/std@$STD_VERSION/log/mod.ts";
```

In order to increment this version, you can update the `import` statement and
Expand Down
4 changes: 2 additions & 2 deletions runtime/manual/advanced/deploying_deno/kinsta.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ To do so, your `package.json` should look like this:
## Example application

```js
import { serve } from "https://deno.land/std/http/server.ts";
import { parse } from "https://deno.land/std/flags/mod.ts";
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
import { parse } from "https://deno.land/std@$STD_VERSION/flags/mod.ts";

const { args } = Deno;
const argPort = parse(args).port ? Number(parse(args).port) : 8000;
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/advanced/jsx_dom/css.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Then we will stringify the modified CSS AST and output it to the console:

```ts, ignore
import * as css from "https://esm.sh/css@3.0.0";
import { assert } from "https://deno.land/std/assert/mod.ts";
import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts";
declare global {
interface AbortSignal {
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/advanced/jsx_dom/deno_dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ first heading it encounters and print out the text content of that heading:

```ts
import { DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
import { assert } from "https://deno.land/std/assert/mod.ts";
import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts";

const document = new DOMParser().parseFromString(
`<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/advanced/jsx_dom/jsdom.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ first heading it encounters and print out the text content of that heading:

```ts, ignore
import { JSDOM } from "jsdom";
import { assert } from "https://deno.land/std/assert/mod.ts";
import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts";
const { window: { document } } = new JSDOM(
`<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/advanced/jsx_dom/linkedom.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ first heading it encounters and print out the text content of that heading:

```ts
import { DOMParser } from "https://esm.sh/linkedom";
import { assert } from "https://deno.land/std/assert/mod.ts";
import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts";

const document = new DOMParser().parseFromString(
`<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/basics/connecting_to_databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ for Deno, to run a GraphQL API server in Deno.
#### Run a GraphQL API server with gql

```ts, ignore
import { Server } from "https://deno.land/std/http/server.ts";
import { Server } from "https://deno.land/std@$STD_VERSION/http/server.ts";
import { GraphQLHTTP } from "https://deno.land/x/gql/mod.ts";
import { makeExecutableSchema } from "https://deno.land/x/graphql_tools@0.0.2/mod.ts";
import { gql } from "https://deno.land/x/graphql_tag@0.0.1/mod.ts";
Expand Down
Loading

0 comments on commit 4077356

Please sign in to comment.