|
1 |
| -import "jsr:@std/dotenv/load"; |
| 1 | +import 'jsr:@std/dotenv/load'; |
2 | 2 |
|
3 |
| -import { parseArgs } from "jsr:@std/cli/parse-args"; |
4 |
| -import { randomIntegerBetween } from "jsr:@std/random"; |
| 3 | +import { parseArgs } from 'jsr:@std/cli/parse-args'; |
| 4 | +import { randomIntegerBetween } from 'jsr:@std/random'; |
5 | 5 |
|
6 | 6 | interface User {
|
7 |
| - id: string; |
8 |
| - email: string; |
| 7 | + id: string; |
| 8 | + email: string; |
9 | 9 | }
|
10 | 10 |
|
11 | 11 | const args = parseArgs(Deno.args, {
|
12 |
| - string: ["url"], |
13 |
| - boolean: ["dry"], |
| 12 | + string: ['url'], |
| 13 | + boolean: ['dry'], |
14 | 14 | });
|
15 | 15 |
|
16 |
| -const user = await fetch( |
17 |
| - `https://dummyjson.com/users/${randomIntegerBetween(1, 100)}`, |
18 |
| -).then((data) => data.json()) as User; |
| 16 | +const user = (await fetch( |
| 17 | + `https://dummyjson.com/users/${randomIntegerBetween(1, 100)}`, |
| 18 | +).then((data) => data.json())) as User; |
19 | 19 |
|
20 | 20 | const data = {
|
21 |
| - user: { |
22 |
| - id: user.id, |
23 |
| - email: user.email, |
24 |
| - }, |
25 |
| - args: { ...args }, |
26 |
| - env: { token: Deno.env.get("API_TOKEN") }, |
| 21 | + user: { |
| 22 | + id: user.id, |
| 23 | + email: user.email, |
| 24 | + }, |
| 25 | + args: { ...args }, |
| 26 | + env: { token: Deno.env.get('API_TOKEN') }, |
27 | 27 | };
|
28 | 28 |
|
29 |
| -Deno.writeTextFile( |
30 |
| - "input.json", |
31 |
| - JSON.stringify( |
32 |
| - data, |
33 |
| - null, |
34 |
| - 2, |
35 |
| - ), |
36 |
| -); |
| 29 | +Deno.writeTextFile('input.json', JSON.stringify(data, null, 2)); |
37 | 30 |
|
38 | 31 | console.log(
|
39 |
| - "%cExecution completed.", |
40 |
| - "color: green", |
41 |
| - "\n", |
42 |
| - JSON.stringify({ data }, null, 2), |
| 32 | + '%cExecution completed.', |
| 33 | + 'color: green', |
| 34 | + '\n', |
| 35 | + JSON.stringify({ data }, null, 2), |
43 | 36 | );
|
0 commit comments