Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .github/docs/prd.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ VitNode is designed for individual developers and small teams who need a structu
- Component scaffolding
- API endpoint generation
- Database schema generation from models
- Logging system with structured logs:
- Log levels (debug, info, warn, error)
- Contextual logging with request/response metadata

### File Management

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/dev/config/rate-limiter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { TypeTable } from 'fumadocs-ui/components/type-table';
description:
'The number of requests allowed within the specified duration.',
type: 'number',
default: '40',
default: '80 (120 in dev)',
},
duration: {
description:
Expand Down
9 changes: 2 additions & 7 deletions apps/docs/content/docs/dev/database/pagination.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,13 @@ On the frontend, the pagination system works seamlessly with the DataTable compo
When fetching data from the API, include the pagination parameters in your request:

```tsx
const query = await searchParams; // Assume searchParams is a Promise from the Next.js page context
const res = await fetcher(userModule, {
path: '/users',
method: 'get',
module: 'user',
args: {
query: {
cursor: searchParams.cursor,
first: searchParams.first,
last: searchParams.last,
order: searchParams.order,
orderBy: searchParams.orderBy,
},
query,
},
withPagination: true, // Important flag for pagination
});
Expand Down
22 changes: 22 additions & 0 deletions apps/docs/content/docs/dev/fetcher.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ The fetcher returns a standard Response object, just like the native `fetch` API

## Advanced Features

### Path Prefixing

When working with nested modules you can import the module and use it directly with the `fetcher` function and add the `prefixPath` option to specify a path prefix. This is useful for organizing your API endpoints and keeping them modular.

```ts
const response = await fetcher(categoriesAdminModule, {
// [!code ++]
prefixPath: '/admin', // Adds prefix to the path
path: '/categories',
method: 'post',
module: 'categories',
args: {
body: {
name: 'Technology',
description: 'Tech-related articles',
},
},
});

// This will make a request to: /admin/categories
```

### Caching Responses

You can leverage Next.js caching by passing cache options:
Expand Down
45 changes: 44 additions & 1 deletion apps/docs/content/docs/dev/logging.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,47 @@
---
title: Logging
description: Centralized logging with VitNode
description: Structured logging system for VitNode applications
---

VitNode provides a logging system that allows you to log messages at different levels _(debug, warn, error)_ with structured logs. This is useful for debugging and monitoring your application.

All logs are stored in your database. You can view them in the `Debug Panel`.

## Usage

```ts
import { buildRoute } from '@vitnode/core/api/lib/route';
```

```ts
export const testRoute = buildRoute(
{},
{
handler: c => {
c.get('log').warn('This is a test warn log'); // [!code ++]

return c.text('test');
},
},
);
```

### Variants

import { Tab, Tabs } from 'fumadocs-ui/components/tabs';

<Tabs id='logging-variants' persist items={['Debug', 'Warn', 'Error']}>

```ts tab="Debug"
c.get('log').debug('This is a test debug log');
```

```ts tab="Warn"
c.get('log').warn('This is a test warning log');
```

```ts tab="Error"
c.get('log').error('This is a test error log');
```

</Tabs>
10 changes: 5 additions & 5 deletions apps/docs/src/app/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
--muted-foreground: oklch(0.45 0 0);
--accent: oklch(0.95 0 0);
--accent-foreground: oklch(0.205 0 0);
--destructive: oklch(0.577 0.245 27.325);
--destructive-foreground: oklch(0.577 0.245 27.325);
--destructive: oklch(0.6 0.2 24.45);
--warn: oklch(0.57 0.13 82.37);
--border: oklch(0.9 0 0);
--input: oklch(0.9 0 0);
--ring: oklch(0.7 0.16 262.61);
Expand Down Expand Up @@ -58,8 +58,8 @@
--muted: oklch(0.22 0 0);
--muted-foreground: oklch(0.7 0 0);
--accent: oklch(0.28 0 0);
--destructive: oklch(0.704 0.191 22.216);
--destructive-foreground: oklch(0.704 0.191 22.216);
--destructive: oklch(0.62 0.2 25.35);
--warn: oklch(0.76 0.18 81.84);
--border: oklch(0.28 0 0);
--input: oklch(0.28 0 0);
--ring: oklch(0.51 0.16 262.61);
Expand Down Expand Up @@ -102,7 +102,7 @@
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-destructive: var(--destructive);
--color-destructive-foreground: var(--destructive-foreground);
--color-warn: var(--warn);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CREATE TYPE "public"."coreLogsType" AS ENUM('warn', 'error', 'debug');--> statement-breakpoint
CREATE TABLE "core_admin_permissions" (
"id" serial PRIMARY KEY NOT NULL,
"roleId" integer,
Expand Down Expand Up @@ -46,6 +47,16 @@ CREATE TABLE "core_languages_words" (
);
--> statement-breakpoint
ALTER TABLE "core_languages_words" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "core_logs" (
"id" serial PRIMARY KEY NOT NULL,
"pluginId" varchar(255) NOT NULL,
"type" "coreLogsType" NOT NULL,
"content" text NOT NULL,
"createdAt" timestamp DEFAULT now() NOT NULL,
"ipAddress" varchar(45) NOT NULL
);
--> statement-breakpoint
ALTER TABLE "core_logs" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "core_moderators_permissions" (
"id" serial PRIMARY KEY NOT NULL,
"roleId" integer,
Expand Down Expand Up @@ -81,9 +92,11 @@ CREATE TABLE "core_sessions" (
ALTER TABLE "core_sessions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "core_sessions_known_devices" (
"id" serial PRIMARY KEY NOT NULL,
"publicId" varchar(32) NOT NULL,
"ipAddress" varchar(40) NOT NULL,
"userAgent" text NOT NULL,
"lastSeen" timestamp DEFAULT now() NOT NULL
"lastSeen" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "core_sessions_known_devices_publicId_unique" UNIQUE("publicId")
);
--> statement-breakpoint
ALTER TABLE "core_sessions_known_devices" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
Expand Down
2 changes: 0 additions & 2 deletions apps/web/migrations/0001_mute_flatman.sql

This file was deleted.

13 changes: 0 additions & 13 deletions apps/web/migrations/0002_superb_natasha_romanoff.sql

This file was deleted.

81 changes: 78 additions & 3 deletions apps/web/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "d8197fc3-2d92-4d22-9381-9ebb1412c8fc",
"id": "960a9871-cd4a-4144-bc0a-af0717f397a7",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
Expand Down Expand Up @@ -439,6 +439,57 @@
"checkConstraints": {},
"isRLSEnabled": true
},
"public.core_logs": {
"name": "core_logs",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"pluginId": {
"name": "pluginId",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"type": {
"name": "type",
"type": "coreLogsType",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"content": {
"name": "content",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"ipAddress": {
"name": "ipAddress",
"type": "varchar(45)",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": true
},
"public.core_moderators_permissions": {
"name": "core_moderators_permissions",
"schema": "",
Expand Down Expand Up @@ -725,6 +776,12 @@
"primaryKey": true,
"notNull": true
},
"publicId": {
"name": "publicId",
"type": "varchar(32)",
"primaryKey": false,
"notNull": true
},
"ipAddress": {
"name": "ipAddress",
"type": "varchar(40)",
Expand Down Expand Up @@ -764,7 +821,15 @@
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"uniqueConstraints": {
"core_sessions_known_devices_publicId_unique": {
"name": "core_sessions_known_devices_publicId_unique",
"nullsNotDistinct": false,
"columns": [
"publicId"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": true
Expand Down Expand Up @@ -1310,7 +1375,17 @@
"isRLSEnabled": true
}
},
"enums": {},
"enums": {
"public.coreLogsType": {
"name": "coreLogsType",
"schema": "public",
"values": [
"warn",
"error",
"debug"
]
}
},
"schemas": {},
"sequences": {},
"roles": {},
Expand Down
Loading