Simply generate a new api route with npx green_dot generate and configure it:
export const
const getUserByEmail:void
getUserByEmail =
functionsvc(config: {
for: [string| {
role:string;
hasValidatedEmail:boolean;
}];
main(ctx: {
_id:string;
role:"appUser";
}, body: {
email:string;
}):any;
}):void
svc({
for: [string | {
role: string;
hasValidatedEmail: boolean;
}]
for: [
'customRole',
{
role: string
role: 'user',
hasValidatedEmail: boolean
hasValidatedEmail: true }
],
input: {
email: any;
}
input: {
email: any
email:
any
_.
any
email().
any
required(),
},
output: any
output:
any
_.
any
model('myDbName', 'user'),
rateLimiter: string
rateLimiter: '10/min',
...
any
async
functionmain(ctx: {
_id:string;
role:"appUser";
}, body: {
email:string;
}):any
main(
ctx: {
_id: string;
role: "appUser";
}
ctx, { email }) {
email: string
return await
any
db.
any
user.
any
getOne(
ctx: {
_id: string;
role: "appUser";
}
ctx, {
email: string
email }) // this db call will automatically apply mask and filter depending on user perm (see below)
},
})
Note: the above will auto generate a route on POST myDomain.com/get-user-by-email based on the const value. You can modify this by adding a route and method config