@cvo/plugin-douyin
v0.0.0
Published
Douyin (ByteDance) plugin for CVO Framework
Downloads
42
Readme
CVO Douyin Plugin
ByteDance (Douyin/Toutiao) mini-program authentication plugin for CVO Framework.
Installation
pnpm add @cvo/plugin-douyinUsage
Server Configuration
Add the plugin to your cvo.config.ts:
import { DouyinPlugin } from '@cvo/plugin-douyin';
export default defineConfig({
plugins: [
new DouyinPlugin({
appid: process.env.DOUYIN_APPID,
secret: process.env.DOUYIN_SECRET,
}),
],
});Controller Usage
import { useDouyin } from '@cvo/plugin-douyin';
@http('/api/user')
export class UserController {
@http('POST', '/login')
async login(@Body body: any) {
const { code, anonymousCode } = body;
const douyin = useDouyin();
const openid = await douyin.getService().getOpenid(code, anonymousCode);
// ... handle user login
}
}