Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eicrud/eicrud
An opinionated backend framework based on NestJS. Get your CRUD app up and running in no time! βοΈπ
https://github.com/eicrud/eicrud
authentication authorization backend casl crud crud-application framework hacktoberfest javascript microservices mikro-orm nest nestjs nodejs nodejs-framework typescript
Last synced: 7 days ago
JSON representation
An opinionated backend framework based on NestJS. Get your CRUD app up and running in no time! βοΈπ
- Host: GitHub
- URL: https://github.com/eicrud/eicrud
- Owner: eicrud
- License: mit
- Created: 2024-04-07T10:34:51.000Z (8 months ago)
- Default Branch: develop
- Last Pushed: 2024-10-28T23:46:13.000Z (about 1 month ago)
- Last Synced: 2024-10-29T15:19:28.046Z (about 1 month ago)
- Topics: authentication, authorization, backend, casl, crud, crud-application, framework, hacktoberfest, javascript, microservices, mikro-orm, nest, nestjs, nodejs, nodejs-framework, typescript
- Language: TypeScript
- Homepage: https://eicrud.com
- Size: 2.16 MB
- Stars: 651
- Watchers: 6
- Forks: 18
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-nestjs - Eicrud - An opinionated framework that extends NestJS with CRUD services, user management commands, and authorization controls. (Projects using NestJS)
README
Eicrud is an opinionated backend framework extending NestJS.
It's a tool for building scalable, secure Node.js server applications in record time.> [!IMPORTANT]
> *Eicrud is still in beta; expect minor breaking changes with new versions untilΒ **v1.0.0**. However, you can still use it as it is, and the API will not change much. Check out the [release notes](https://github.com/eicrud/eicrud/releases) for migration guides. If you're interested in the project, please leave a star on the repository; it helps a lot ππ*## Philosophy
Most of the time, a web app has some CRUD functionality as its base. Eicrud abstracts this into a simple and easy-to-use API, so you don't have to re-write boilerplate code (controllers, validations, db queries...) whenever you need a new service. By centering everything around CRUD entities, Eicrud provides a framework for writing complex applications that are easy to read, test, and maintain. Eicrud also emphasizes "default security" for its components, where everything is forbidden until allowed.
## Features
- βοΈ Out of the box [CRUD services](https://docs.eicrud.com/services/definition)
- π [Authentication & user management](https://docs.eicrud.com/user/service/)
- π [Authorization](https://docs.eicrud.com/security/definition/)
- π₯οΈ [Commands](https://docs.eicrud.com/services/commands/)
- βοΈ [Validation/Transform](https://docs.eicrud.com/validation/definition/)
- ποΈ [Database control](https://docs.eicrud.com/configuration/limits)
- π Easy to use (RPC) [client](https://docs.eicrud.com/client/setup)
- π [Monolithic/Microservices](https://docs.eicrud.com/microservices/configuration/)
- And more!
## How it works
Under the hood, **Eicrud** uses [MikroOrm](https://mikro-orm.io/) entities guarded with [CASL](https://casl.js.org) and [class-validator](https://github.com/typestack/class-validator).
### Here's a quick example
You first define your entity with validations and transforms (what the data can be).```typescript
@Entity()
export class Profile {
@PrimaryKey()
@IsString()
@IsOptional()
id: string;@OneToOne(() => MyUser, (user) => user.profile)
@IsString()
owner: MyUser | string;@Property()
@$Transform((val) => val.toLowerCase())
@MaxLength(30)
userName: string;
}
```Then define your security (who can access the data).
```typescript
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');
},
},
};
```And finally, register your service.
```typescript
@Injectable()
export class ProfileService extends CrudService {
constructor(protected moduleRef: ModuleRef) {
super(moduleRef, Profile, security);
}
}
```**That's it**, `profile` is now a fully operational CRUD service that you can query with the [client](https://docs.eicrud.com/client/setup/).
```typescript
const client = new CrudClient({ serviceName: 'profile' });const res = await client.findOne({ userName: 'jon doe' });
```You can extend it using [commands](https://docs.eicrud.com/services/commands/) (for non-CRUD operations).
## Monolithic/Microservices duality
**Eicrud** lets you group your CRUD services into "microservices" with a simple configuration. You can start developing a monolith and easily switch to microservices later on.
```typescript
msOptions.microServices = {
"entry": {
services: [],
openMsLink: false, openController: true,
url: "http://localhost:3004",
},
"users": {
services: [User, Profile],
openMsLink: true, openController: false,
url: "http://localhost:3005",
},
"orders": {
services: [Order],
openMsLink: true, openController: false,
url: "http://localhost:3006",
},
}
```## Powerful typed client (remote procedure call)
**Eicrud** lets you generate a powerful super-client that holds all your DTOs and commands. Allowing auto-completion and type safety directly in your front-end.
```typescript
// in your profile service
async $say_hello(dto: SayHelloDto, ctx: CrudContext) {
return `Hello ${dto.myArg}!`
}// in your frontend
const sp = new SuperClient({url: 'http://localhost:3004'});
sp.profile.say_hello({myArg: 'world'}).then(console.log);
```## Start building
**Eicrud** is made for code simplicity, you can build your applications in record time using the [CLI](https://www.npmjs.com/package/@eicrud/cli) that will do the heavy work for you.
Check out the [documentation](https://docs.eicrud.com/installation) to get started.
## Support
**Eicrud** is in active development and issues are taken seriously. Don't hesitate to create a [ticket](https://github.com/eicrud/eicrud/issues) or join the [Discord](https://discord.gg/VaGPqE7bn9) if you need help.