
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
pocketbase-tools
Advanced tools
一个用于 PocketBase 的 TypeScript 工具库,提供完整的客户端管理、服务操作和类型定义。
npm install pocketbase-tools
# 或
yarn add pocketbase-tools
# 或
bun add pocketbase-tools
# 开发环境构建(未压缩,包含 source map)
bun run build:dev
# 生产环境构建(压缩混淆,移除 console)
bun run build:prod
# 默认构建(等同于 build:prod)
bun run build
# 格式化所有代码
bun run format
# 检查代码格式
bun run format:check
# 生成文档
bun run docs
# 运行测试
bun run test
# 监听测试
bun run test:watch
# 安装依赖
bun run setup
src/
├── base/ # 基础客户端和设置
│ ├── client.ts # PocketBase 客户端管理
│ └── setup.ts # 集合预设置
├── services/ # 业务服务
│ ├── auth.action.ts # 认证服务
│ ├── product.action.ts # 产品服务
│ ├── profile.action.ts # 配置文件服务
│ └── user.action.ts # 用户服务
├── types/ # 类型定义
│ ├── index.ts # 类型导出
│ ├── product.types.ts # 产品类型
│ ├── profile.types.ts # 配置文件类型
│ └── user.types.ts # 用户类型
├── utils/ # 工具函数
│ ├── index.ts # 工具导出
│ ├── env.ts # 环境变量处理
│ ├── errorHandler.ts # 错误处理
│ ├── logger.ts # 日志工具
│ └── useFiles.ts # 文件处理
└── index.ts # 主入口文件
.prettierrc).eslintrc.js)vite.config.ts)import { usePBClient, resetPBInstances } from "pocketbase-tools";
import {
getCollect,
userCollect,
productCollect,
profileCollect,
} from "pocketbase-tools";
import pb from "pocketbase-tools";
import {
// 认证服务
useAuth,
// 产品服务
addProduct,
updateProduct,
deleteProduct,
getAllProducts,
getProductById,
// 用户服务
getAllUsers,
addUser,
updateUser,
deleteUser,
// 配置文件服务
listAllCompanyProfiles,
addCompanyProfile,
updateCompanyProfile,
deleteCompanyProfile,
} from "pocketbase-tools";
import {
User,
UserCreate,
UserUpdate,
Product,
ProfileCollection,
} from "pocketbase-tools";
import {
getEnvVar,
validateEnvVars,
withErrorHandling,
logger,
} from "pocketbase-tools";
import { usePBClient, getAllUsers, logger } from "pocketbase-tools";
// 初始化客户端
const pb = usePBClient({
url: "http://localhost:8090",
});
// 或者使用默认的
import pb from "pocketbase-tools";
// 使用服务
const users = await getAllUsers();
logger.success("获取用户列表成功", users);
useAuth)useAuth 提供了灵活的认证方法,支持在登录和刷新时指定 PocketBase 客户端的 URL 或实例。
import { useAuth } from "pocketbase-tools";
import PocketBase from "pocketbase"; // 如果需要直接传入实例
// 示例 1: 登录时指定自定义 URL
const adminLoginWithUrl = await useAuth.login('admin', {
email: 'admin@gmail.com',
password: 'admin123456',
}, {
url: 'http://127.0.0.1:8090', // 指定 PocketBase 服务地址
});
logger.success('管理员通过自定义 URL 登录成功', adminLoginWithUrl.record);
// 示例 2: 登录时指定自定义 PocketBase 实例
const customPbInstance = new PocketBase('http://127.0.0.1:8090');
const adminLoginWithInstance = await useAuth.login('admin', {
email: 'admin@gmail.com',
password: 'admin123456',
}, {
instance: customPbInstance, // 传入自定义 PocketBase 实例
});
logger.success('管理员通过自定义实例登录成功', adminLoginWithInstance.record);
// 示例 3: 使用默认配置的客户端 (例如,通过环境变量 VITE_POCKETBASE_URL 配置)
const adminLoginDefault = await useAuth.login('admin', {
email: 'admin@gmail.com',
password: 'admin123456',
});
logger.success('管理员通过默认客户端登录成功', adminLoginDefault.record);
// 刷新认证信息时也可以使用 clientOptions
const refreshedAuth = await useAuth.refresh('admin', { url: 'http://127.0.0.1:8090' });
logger.success('刷新认证信息成功', refreshedAuth.record);
import { filesCollect } from "pocketbase-tools";
// 获取最新的文件记录
const [record] = await filesCollect.getFullList({
sort: '-created',
limit: 1,
});
// 获取文件信息
console.log(useFiles.getAbsoluteURL(record, record?.file))
项目配置了 prepack 钩子,在发布前会自动执行生产环境构建:
npm publish
# 会自动执行: bun run build:prod
bun run format 确保代码格式正确bun run build:prod 测试生产环境构建MIT License
FAQs
Unknown package
We found that pocketbase-tools demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.