2024-10-26 08:35:59 +00:00
< p align = "center" >
< a href = "http://nestjs.com/" target = "blank" > < img src = "https://nestjs.com/img/logo-small.svg" width = "120" alt = "Nest Logo" / > < / a >
< / p >
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
< p align = "center" > A progressive < a href = "http://nodejs.org" target = "_blank" > Node.js< / a > framework for building efficient and scalable server-side applications.< / p >
< p align = "center" >
2024-10-28 19:09:35 +00:00
## Status
2024-10-26 08:35:59 +00:00
2024-10-28 19:09:35 +00:00
This project is still in development and not ready for production, it's not even ready to install yet. Calling for contributors to help this project.
2024-10-26 10:31:59 +00:00
2024-10-28 19:09:35 +00:00
## Description
2024-10-26 08:35:59 +00:00
2024-10-28 19:09:35 +00:00
Nest Auto CRUD is a library that provides a set of modules, decorator, service, and many more to reduce the boilerplate code.
2024-10-26 08:35:59 +00:00
2024-11-10 05:40:44 +00:00
**I will make the API backward compatible, so you don't need to worry about upgrading the version**
2024-11-10 05:14:34 +00:00
2024-10-28 19:09:35 +00:00
## Roadmap
2024-10-26 08:35:59 +00:00
2024-10-30 14:00:49 +00:00
### Basic Thing
- Custom body mapping
2024-10-30 14:09:27 +00:00
- Custom validation
2024-10-30 14:00:49 +00:00
### Advanced Support
- Generic support for Prisma ORM [#5273 ](https://github.com/prisma/prisma/issues/5273 )
2024-10-26 08:35:59 +00:00
2024-10-28 19:09:35 +00:00
## Installation
2024-10-26 08:35:59 +00:00
```bash
2024-10-28 19:09:35 +00:00
$ npm install @aditama -labs/nest-autocrud
2024-10-26 08:35:59 +00:00
```
2024-10-28 19:22:40 +00:00
## Example
2024-11-10 05:02:28 +00:00
### Environment Variable
```typescript
// Yes, either Prisma or TypeORM just need this single line of ENV
// PostgreSQL Example
2024-11-10 05:14:34 +00:00
DATABASE_URL =
'postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public';
2024-11-10 05:02:28 +00:00
// MySQL Example
2024-11-10 05:14:34 +00:00
DATABASE_URL = 'mysql://johndoe:randompassword@localhost:3306/mydb';
2024-11-10 05:02:28 +00:00
```
2024-10-28 19:22:40 +00:00
### Prisma ORM
```typescript
// Your Module
@Module ({
imports: [
2024-10-30 14:03:57 +00:00
// This module will automatically map your model to the controller
2024-10-28 19:22:40 +00:00
PrismaModule.forRoot({
2024-10-30 14:03:57 +00:00
delegate: (prisma: PrismaClient) => prisma.user,
2024-10-28 19:22:40 +00:00
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
// Your Controller
@Controller ('examples')
2024-10-31 01:17:11 +00:00
export class AppController extends SkeletonCRUDController {
// Yes, no need to write anything here
}
2024-11-10 04:46:06 +00:00
```
### TypeORM
```typescript
// Your Entity
@Entity ('account')
export class UserEntity {
@PrimaryGeneratedColumn ('uuid')
id: string;
@Column ({ type: String })
username: string;
@Column ({ type: String })
name: string;
}
2024-10-30 14:12:59 +00:00
2024-11-10 04:46:06 +00:00
// Your Module
@Module ({
// This module will automatically map your model to the controller
imports: [
TypeORMModule.forRoot< UserEntity > ({
entity: UserEntity,
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
// Your Controller
@Controller ('examples')
export class AppController extends SkeletonCRUDController {
// Yes, no need to write anything here
}
```
### Output in Terminal
```plaintext
2024-10-31 01:17:11 +00:00
// Expected Output ( As you can see the API is automatically mapped and generated )
2024-10-30 15:58:23 +00:00
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [NestFactory] Starting Nest application...
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [InstanceLoader] PrismaModule dependencies initialized +14ms
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [InstanceLoader] AppModule dependencies initialized +0ms
2024-11-10 04:46:06 +00:00
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [RoutesResolver] AppController {/examples}: +3ms
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [RouterExplorer] Mapped {/examples, POST} route +3ms
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [RouterExplorer] Mapped {/examples/:id, DELETE} route +1ms
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [RouterExplorer] Mapped {/examples/list, GET} route +0ms
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [RouterExplorer] Mapped {/examples, GET} route +1ms
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [RouterExplorer] Mapped {/examples/:id, GET} route +0ms
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [RouterExplorer] Mapped {/examples/:id, PATCH} route +0ms
2024-10-30 15:58:23 +00:00
[Nest] 125875 - 10/30/2024, 10:57:56 PM LOG [NestApplication] Nest application successfully started +148ms
2024-10-28 19:22:40 +00:00
```
2024-10-26 08:35:59 +00:00
## Support
2024-10-28 19:09:35 +00:00
Nest AutoCRUD is an MIT-licensed open source project.
2024-10-26 08:35:59 +00:00
## Stay in touch
2024-10-28 19:09:35 +00:00
- Author - [Supan Adit Pratama ](mailto:email@supanadit.com )
- Website - [https://supanadit.com ](https://supanadit.com/ )
2024-10-26 08:35:59 +00:00
## License
2024-10-28 19:09:35 +00:00
Nest AutoCRUD is MIT licensed