Package containing all Rocket.Chat rest endpoint definitions
Contributions are always welcome! However we have some recommendations.
type EndPointTestGetParams = { name?: string; id?: string; } // WRONG!
type EndPointTestGetParams = { name: string; } | { id: string; } // Better :)
export const isEndPointTestGetParams = (props: any) is EndPointTestGetParams => 'name' in prop || 'id' in prop; // WRONG!
// .... Better
import Ajv from 'ajv';
const ajv = new Ajv();
const endPointTestGetParams = {
: [
oneOf
{: 'object',
type: {
properties: {
name: 'string',
type,
},
}: ['name'],
required: false,
additionalProperties,
}
{: 'object',
type: {
properties: {
id: 'string',
type,
},
}: ['id'],
required: false,
additionalProperties,
},
];
}
export const isEndPointTestGetParams = ajv.compile<EndPointTestGetParams>(endPointTestGetParams);
we use interfaces to register endpoints, so if you use a custom version, or miss an endpoint, you don't necessarily need to recompile the code, you can do it in your own code
declare module '@rocket.chat/rest-typings' {
interface Endpoints {
'custom/endpoint': {
: (params: PaginatedRequest<{ query: string }>) => PaginatedResult<{
GET: string[];
some>;
};
}
} }
MIT