🧭 Back/Front Type-safe API route declarations, shared models
🔒 Unified model definitions and security configuration
🔌 Powerful plugin system (Managed Login, ApiKey Login…) (BETA)
🪄 File generation to generate project, databases, apps, models…so you get up and running in no time
🗃️ MongoDB integration with all the way type safety (others database drivers coming soon)
👨💻 DX and intellisense friendly
🏗️ Generate it’s own SDK to use in frontend, get your backend data without await, useEffects or state management: (Eg: const result = $.useQuery.myApiRoute())
⚡ Fully cached in frontend via TanStack Query
📦 VSCode / Cursor Plugin
API route declaration
Generate a new api route with npx green_dot generate and configure it:
getUserByEmailCustom.api.ts
export const
const getUserByEmailCustom:void
getUserByEmailCustom =
functionsvc(config: {
for: [string| {
role:string;
hasValidatedEmail:boolean;
}];
main(ctx: {
_id:string;
role:"appUser";
}, body: {
email:string;
}):any;
rateLimiter:string;
output: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
Type output for security and backend / frontend type safety
output:
any
_.
any
model('myDbName', 'user'),
rateLimiter: string
Custom rate limiter for this route
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
// No need to worry about security here, this db call will automatically apply
// mask and filter depending on user perm (see below)
return await
ctx: {
_id: string;
role: "appUser";
}
ctx.
any
db.
any
user.
any
getOne({
email: string
email })
},
})
Note: the above will auto generate a route on POST myDomain.com/get-user-by-email-custom based on the const value. You can modify this by adding a route and method config
Dao files are a way to configure the security of your model and expose automatically some method via API (getById, update…). Everything is unified in a single file so security is made easy and comprehensive:
company.dao.ts
export const dao = {
type: 'mongo', // other DBs drivers incoming
// EXPOSE: auto generate routes and SDK methods with configured access
expose: [{
for: 'appUser',
expose: ['getOne', 'create'], // so an appUser cannot update or delete
}, {
for: 'admin',
expose: ['read', 'write'], // admin has full access
}],
// FILTER
filter: [{
for: 'appUser',
filter: (ctx, filter)=> {
// here, we force admin fields to be equal to user._id
// in other terms, user must be admin of the company to read/write model
filter.admin=== ctx._id
}
}],
// MASK
mask: [{
for: 'appUser',
mask: ctx=> ({
// user cannot see businessData field
businessData: true,
}),
}, {
on: 'read',
mask: ctx=> ({
// no one can read password
password: true,
// dynamically hide fields according to user perms
businessData: ctx.isBusinessHolder,
}),
}],
// automatically populate (left join) data for this model,
// security is applied to any level of populated field