Skip to content

Commit 3c7c90a

Browse files
committed
chore: Use dedent in examples
1 parent a746d13 commit 3c7c90a

3 files changed

Lines changed: 26 additions & 31 deletions

File tree

examples/cookie-auth/main.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
UnauthorizedHttpError,
88
} from "@aklinker1/zeta";
99
import * as cookie from "cookie";
10+
import dedent from "dedent";
1011
import z from "zod";
1112
import type { Setter } from "../../src/types";
1213

@@ -215,25 +216,15 @@ const app = createApp()
215216
);
216217

217218
app.listen(3000, () => {
218-
console.log("Example server started!");
219-
console.log("");
220-
console.log("Try out using cookies for auth:");
221-
console.log(
222-
"1. Visit http://localhost:3000 and get a 401 since you're not logged in.",
223-
);
224-
console.log(
225-
"2. Log in with tom and you will be redirected to the homepage to see the user details: http://localhost:3000/login?username=tom&password=toms-password",
226-
);
227-
console.log(
228-
"3. Try to get the list of users, but see you get a 403 because tom is missing the required permission: http://localhost:3000/users",
229-
);
230-
console.log(
231-
"4. Log out of Tom's account at http://localhost:3000/logout - You will be redirected back to the homepage with a 401",
232-
);
233-
console.log(
234-
"5. Log in as aaron: http://localhost:3000/login?username=aaron&password=aarons-password",
235-
);
236-
console.log(
237-
"6. Now you can access the list of users: http://localhost:3000/users",
238-
);
219+
console.log(dedent`
220+
Example server started!
221+
222+
Try out using cookies for auth:
223+
1. Visit http://localhost:3000 and get a 401 since you're not logged in.
224+
2. Log in with tom and you will be redirected to the homepage to see the user details: http://localhost:3000/login?username=tom&password=toms-password
225+
3. Try to get the list of users, but see you get a 403 because tom is missing the required permission: http://localhost:3000/users
226+
4. Log out of Tom's account at http://localhost:3000/logout - You will be redirected back to the homepage with a 401
227+
5. Log in as aaron: http://localhost:3000/login?username=aaron&password=aarons-password
228+
6. Now you can access the list of users: http://localhost:3000/users
229+
`);
239230
});

examples/open-telemetry/main.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ATTR_SERVICE_NAME,
88
ATTR_SERVICE_VERSION,
99
} from "@opentelemetry/semantic-conventions";
10+
import dedent from "dedent";
1011

1112
// Initialize you SDK: https://opentelemetry.io/docs/languages/js/instrumentation
1213
const sdk = new NodeSDK({
@@ -40,9 +41,9 @@ const app = createApp()
4041
.get("/", () => "OK");
4142

4243
app.listen(3000, () => {
43-
console.log("Open telemetry example started.");
44-
console.log("");
45-
console.log(
46-
"Open http://localhost:3000. It might take a few seconds after opening the URL to see the span in the console.",
47-
);
44+
console.log(dedent`
45+
Open telemetry example started.
46+
47+
Open http://localhost:3000. It might take a few seconds after opening the URL to see the span in the console.
48+
`);
4849
});

examples/request-logger/main.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createApp } from "@aklinker1/zeta";
2+
import dedent from "dedent";
23

34
// For an overview of when each hook is called, see:
45
// https://zeta.aklinker1.io/server/hooks
@@ -53,9 +54,11 @@ const app = createApp()
5354
.get("/example", () => "OK");
5455

5556
app.listen(3000, () => {
56-
console.log("Request logger example started!");
57-
console.log("");
58-
console.log("Visit the URLs below to see the request logs:");
59-
console.log(" - http://localhost:3000");
60-
console.log(" - http://localhost:3000/example");
57+
console.log(dedent`
58+
Request logger example started!
59+
60+
Visit the URLs below to see the request logs:
61+
- http://localhost:3000
62+
- http://localhost:3000/example
63+
`);
6164
});

0 commit comments

Comments
 (0)