EICRUD

A typescript back-end framework for building secure and scalable web applications.

Eicrud extends NestJS / Node.js, works with MikroOrm, CASL and class-validator.

- Features -

Database schema, DTO, validations: in one place.

  @Entity()
export class Profile {
    @PrimaryKey()
    @IsString()
    @IsOptional()
    id: string;

    @OneToOne(() => User, user => user.profile)
    @IsString()
    owner: User | string;

    @Property()
    @$Transform((val) => val.toLowerCase())
    @MaxLength(30)
    userName: string;
}
        

Explicit, highly customizable access rules.

  const security: CrudSecurity = {
  user: {
    async defineCRUDAbility(can, cannot, ctx) {
     const id = ctx.userId;
     // users can crud their own profile 
     can('crud', 'profile', { owner: id });
    }
  },
  guest: {
    async defineCRUDAbility(can, cannot, ctx) {
     // guests can read all profiles
     can('read', 'profile')
    }
  }
}

        

Functional CRUD services built in minutes.

  @Injectable()
export class ProfileService extends CrudService {
  constructor(protected moduleRef: ModuleRef) {
      super(moduleRef, Profile, security);
  }
}

// in your front-end
const client = new CrudClient({serviceName: 'profile'})
const res = await client.findOne({userName: 'John Doe'})

Dynamic microservices configuration.

  msOptions.microServices = {
  "entry": {
    services: [],
    openBackDoor: false, openController: true,
    url: "http://localhost:3004",
  },
  "users": {
    services: [User, Profile],
    openBackDoor: true, openController: false,
    url: "http://localhost:3005",
  },
  "orders": {
    services: [Order],
    openBackDoor: true, openController: false,
    url: "http://localhost:3006",
  },
}

Powerful typed client (remote procedure call).

  // in your profile service
async $say_hello(dto: SayHelloDto, ctx: CrudContext) {
    return `Hello ${dto.arg}!`
}

// in your frontend
const sp = new SuperClient({url: 'http://localhost:3004'});
sp.profile.say_hello({myArg: 'world'}).then(console.log);

And more!

Check out the documentation to learn about Commands, Authentication and all the features.