Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"private": true,
"type": "module",
"scripts": {
"db:push": "vitnode push",
"db:migrate": "vitnode migrate",
"init": "vitnode init --api",
"dev": "tsx watch src/index.ts",
"dev:email": "email dev --dir src/emails",
Expand Down
28 changes: 14 additions & 14 deletions apps/docs/content/docs/dev/api/modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ description: xxx
Think of modules as containers for related API endpoints. They help organize your routes logically - perfect for keeping your sanity intact!

```ts title="plugins/blog/src/api/modules/categories/categories.module.ts"
import { buildModule } from '@vitnode/core/api/lib/module';
import { buildModule } from "@vitnode/core/api/lib/module";

import { CONFIG_PLUGIN } from '@/config';
import { CONFIG_PLUGIN } from "@/config";

export const categoriesModule = buildModule({
pluginId: CONFIG_PLUGIN.id,
name: 'categories',
routes: [], // We'll populate this soon!
name: "categories",
routes: [] // We'll populate this soon!
});
```

Expand All @@ -24,17 +24,17 @@ export const categoriesModule = buildModule({
Want to create a module hierarchy? VitNode's got your back! Nested modules are perfect for complex APIs.

```ts title="plugins/blog/src/api/modules/categories/categories.module.ts"
import { buildModule } from '@vitnode/core/api/lib/module';
import { buildModule } from "@vitnode/core/api/lib/module";

import { CONFIG_PLUGIN } from '@/config';
import { CONFIG_PLUGIN } from "@/config";

import { postsModule } from './posts/posts.module'; // [!code ++]
import { postsModule } from "./posts/posts.module"; // [!code ++]

export const categoriesModule = buildModule({
pluginId: CONFIG_PLUGIN.id,
name: 'categories',
name: "categories",
routes: [],
modules: [postsModule], // [!code ++]
modules: [postsModule] // [!code ++]
});
```

Expand All @@ -43,16 +43,16 @@ This creates a structure: `/api/{plugin_id}/categories/posts/*`
## Connecting Modules to the API

```ts title="plugins/blog/src/config.api.ts"
import { buildApiPlugin } from '@vitnode/core/api/lib/plugin';
import { buildApiPlugin } from "@vitnode/core/api/lib/plugin";

import { CONFIG_PLUGIN } from '@/config';
import { CONFIG_PLUGIN } from "@/config";

import { categoriesModule } from './api/modules/categories/categories.module'; // [!code ++]
import { categoriesModule } from "./api/modules/categories/categories.module"; // [!code ++]

export const blogApiPlugin = () => {
return buildApiPlugin({
...CONFIG_PLUGIN,
modules: [categoriesModule], // [!code ++]
pluginId: CONFIG_PLUGIN.pluginId,
modules: [categoriesModule] // [!code ++]
});
};
```
Loading
Loading