mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-24 22:46:41 +07:00
added vk events handler stub
This commit is contained in:
parent
dfae42c197
commit
3f908da91e
11 changed files with 125 additions and 67 deletions
|
@ -1,20 +1,35 @@
|
|||
import * as yup from 'yup'
|
||||
import { VkConfig, VkEvent } from './types';
|
||||
import * as yup from "yup";
|
||||
import { VkConfig, VkEvent } from "./types";
|
||||
|
||||
const vkChannelEventSchema = yup.string().oneOf(Object.values(VkEvent))
|
||||
const vkChannelEventSchema = yup.string().oneOf(Object.values(VkEvent));
|
||||
|
||||
const vkChannelSchema = yup.object().required().shape({
|
||||
id: yup.string().required().matches(/^@/, ({ path }) => `${path} should start with "@"`),
|
||||
events: yup.array().of(vkChannelEventSchema)
|
||||
})
|
||||
const vkChannelSchema = yup
|
||||
.object()
|
||||
.required()
|
||||
.shape({
|
||||
id: yup
|
||||
.string()
|
||||
.required()
|
||||
.matches(/^@/, ({ path }) => `${path} should start with "@"`),
|
||||
events: yup.array().of(vkChannelEventSchema),
|
||||
});
|
||||
|
||||
export const vkConfigSchema = yup.object<VkConfig>().required().shape({
|
||||
groups: yup.array().required().of(yup.object().shape({
|
||||
id: yup.number().positive(),
|
||||
name: yup.string().required(),
|
||||
testResponse: yup.string().required(),
|
||||
secretKey: yup.string().required(),
|
||||
apiKey: yup.string().required(),
|
||||
channels: yup.array().of(vkChannelSchema),
|
||||
}))
|
||||
})
|
||||
export const vkConfigSchema = yup
|
||||
.object<VkConfig>()
|
||||
.required()
|
||||
.shape({
|
||||
endpoint: yup.string().optional(),
|
||||
groups: yup
|
||||
.array()
|
||||
.required()
|
||||
.of(
|
||||
yup.object().shape({
|
||||
id: yup.number().positive(),
|
||||
name: yup.string().required(),
|
||||
testResponse: yup.string().required(),
|
||||
secretKey: yup.string().required(),
|
||||
apiKey: yup.string().required(),
|
||||
channels: yup.array().of(vkChannelSchema),
|
||||
})
|
||||
),
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue