forked from mengyxu/noob-components
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.2 KiB
71 lines
1.2 KiB
|
3 months ago
|
# Log API
|
||
|
|
|
||
|
|
> `plugs/api/log.ts` - Log operations.
|
||
|
|
|
||
|
|
## Overview
|
||
|
|
|
||
|
|
Action logging API with only list/query functionality. Logs are typically read-only.
|
||
|
|
|
||
|
|
## Endpoint
|
||
|
|
|
||
|
|
- **Root**: `log/action`
|
||
|
|
|
||
|
|
## Exports
|
||
|
|
|
||
|
|
| Function | HTTP | Description |
|
||
|
|
|----------|------|-------------|
|
||
|
|
| `list` | GET | List action logs with filter |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Functions
|
||
|
|
|
||
|
|
### list
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
export const list = (example) => {
|
||
|
|
return queryPage(root, example);
|
||
|
|
};
|
||
|
|
```
|
||
|
|
|
||
|
|
- **Uses**: `queryPage` from base
|
||
|
|
- **URL**: `log/action`
|
||
|
|
- **Parameters**: `example` - Filter criteria (optional)
|
||
|
|
- **Returns**: Paginated result
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Usage Example
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
import { log } from 'plugs/api';
|
||
|
|
|
||
|
|
// List all logs
|
||
|
|
const logs = await log.list();
|
||
|
|
|
||
|
|
// Filter by user
|
||
|
|
const userLogs = await log.list({ userId: 123 });
|
||
|
|
|
||
|
|
// Filter by date range
|
||
|
|
const recentLogs = await log.list({
|
||
|
|
startDate: '2024-01-01',
|
||
|
|
endDate: '2024-01-31'
|
||
|
|
});
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Pattern Notes
|
||
|
|
|
||
|
|
- **Read-only API** - No create, update, or delete operations
|
||
|
|
- **Uses `queryPage`** - Returns paginated results (appropriate for log queries)
|
||
|
|
- URL uses `/action` subpath: `log/action` not just `log`
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Similar Patterns
|
||
|
|
|
||
|
|
Other read-only APIs following this pattern:
|
||
|
|
- `dictionary.ts` uses `queryPage` but has CRUD
|
||
|
|
- `log.ts` is strictly read-only
|