Skip to content

Commit c5b7bab

Browse files
new template generator based documentations
1 parent 6f5dbb5 commit c5b7bab

2 files changed

Lines changed: 23 additions & 88 deletions

File tree

docs/intro.md

Lines changed: 17 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 1
44

55
# Tutorial Intro
66

7-
Let's discover **Yelix in less than 5 minutes**.
7+
Let's discover **Yelix in less than 1 minutes**.
88

99
## Getting Started
1010

@@ -16,98 +16,38 @@ Get started by **creating a new server**.
1616

1717
## Generate a new server
1818

19-
To generate a new server, we should init before.
19+
To generate a new server, run the following command:
2020

2121
```bash
22-
deno init my-app
22+
deno run --allow-write --allow-read https://yelix-docs.deno.dev/yelix-template.ts
2323
```
2424

25-
You can type this command into Command Prompt, Powershell, Terminal, or any other integrated terminal of your code editor.
25+
This command will create a new Yelix project with the following structure:
2626

27-
Move into the newly created directory:
28-
29-
```bash
30-
cd my-app
31-
```
32-
33-
### Install Yelix
34-
35-
To install Yelix, run the following command:
36-
37-
```bash
38-
deno add jsr:@murat/yelix
3927
```
40-
41-
This command installs the Yelix package into your project.
42-
43-
### Update your main file
44-
45-
Open the `main.ts` file in your project and add the following code:
46-
47-
`./main.ts`
48-
```typescript
49-
import { Yelix } from "jsr:@murat/yelix";
50-
import * as path from "jsr:@std/path@1.0.8";
51-
52-
async function main() {
53-
// Port is 3030 by default
54-
const app = new Yelix();
55-
56-
// Load endpoints from a 'api' folder
57-
const currentDir = Deno.cwd();
58-
const API_Folder = path.join(currentDir, 'api');
59-
await app.loadEndpointsFromFolder(API_Folder);
60-
61-
app.serve();
62-
}
63-
64-
await main();
28+
api/
29+
└── hello.ts
30+
deno.json
31+
main.ts
6532
```
6633

67-
This code imports the Yelix package and creates a new server instance. It then loads endpoints from a folder and serves the application.
68-
69-
:::caution
70-
71-
Deno Deploy doesn't support `loadEndpointsFromFolder` method, if you want to deploy your app on Deno Deploy, you should use `loadEndpoints` method.
72-
73-
Deno Deploy doesn't access dynamic importing because of security reasons.
74-
75-
:::
76-
77-
### Create an API folder
34+
### Generated Files
7835

79-
Create a new folder named `api` in your project directory. Inside this folder, create a new file named `hello.ts` with the following content:
36+
| File | Purpose | Description |
37+
|------|---------|-------------|
38+
| `deno.json` | Project Configuration | Contains development tasks and project settings. Defines the `dev` command used to run the server. |
39+
| `main.ts` | Server Setup | Entry point of the application. Initializes Yelix server and configures endpoint loading from the `api` folder. |
40+
| `api/hello.ts` | Example Endpoint | Demonstrates a basic API endpoint that returns "Hello World!" when accessed at `/api/hello`. Shows the standard endpoint structure. |
8041

81-
`./api/hello.ts`
82-
```typescript
83-
import type { Ctx } from "jsr:@murat/yelix";
84-
85-
// API endpoint handler
86-
export async function GET(ctx: Ctx) {
87-
return await ctx.text('Hello World!', 200);
88-
}
89-
90-
// API endpoint configs
91-
export const path = '/api/hello';
92-
```
93-
94-
- Method: `GET` - Taken from the function name
95-
- Path: `/api/hello` - Defined in the `path` variable
96-
- Response: `Hello World!` - Returned by the `GET` function
97-
98-
## Start your site
42+
### Start your server
9943

10044
Run the development server:
10145

10246
```bash
103-
deno run --watch --allow-net --allow-read --allow-env main.ts
47+
deno task dev
10448
```
10549

106-
- `--watch` - Automatically reloads the server when changes are made
107-
- `--allow-net` - Allows network access for serving the server
108-
- `--allow-read` - Allows file read access for loading endpoints
109-
- `--allow-env` - Checking where is deployed for Deno Deploy
110-
50+
This command will start your server in development mode with all required permissions.
11151

11252
| Description | URL |
11353
|------------|-----|

src/pages/landing.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ export const validation: ValidationType = {
254254
</div>
255255
<div className={styles.getStartedContainer}>
256256
<div className={styles.stepCard}>
257-
<h3 className={styles.stepTitle}>1. Install Yelix</h3>
257+
<h3 className={styles.stepTitle}>1. Generate Template</h3>
258258
<pre className={styles.codeBlock}>
259-
<code>deno add jsr:@murat/yelix</code>
259+
<code>deno run --allow-write --allow-read https://yelix-docs.deno.dev/yelix-template.ts</code>
260260
</pre>
261261
</div>
262262

263-
<div className={styles.stepCard}>
263+
{/* <div className={styles.stepCard}>
264264
<h3 className={styles.stepTitle}>2. Create Your First App</h3>
265265
266266
<div className={styles.codeBlock}>
@@ -285,18 +285,13 @@ async function main() {
285285
await main();`}
286286
</SyntaxHighlighter>
287287
</div>
288-
</div>
288+
</div> */}
289289

290290
<div className={styles.stepCard}>
291-
<h3 className={styles.stepTitle}>3. Run Your App</h3>
291+
<h3 className={styles.stepTitle}>2. Run Your App</h3>
292292
<pre className={styles.codeBlock}>
293-
<code>deno run --watch --allow-net --allow-env main.ts</code>
293+
<code>deno task dev</code>
294294
</pre>
295-
<ul>
296-
<li><kbd>--watch:</kbd> Automatically reloads server when changes are made</li>
297-
<li><kbd>--allow-net:</kbd> Permits network access for serving</li>
298-
<li><kbd>--allow-env:</kbd> Checking where is deployed for Deno Deploy</li>
299-
</ul>
300295
</div>
301296

302297
<div className={styles.buttonContainer}>

0 commit comments

Comments
 (0)