Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
janishar committed Jun 26, 2024
1 parent 40f523d commit 1588823
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Check the [Wiki](https://github.com/unusualcodeorg/goserve/wiki/Architecture) fo
Note: We will keep on adding documentations progressively

## Model
api/sample/model/sample.go
`api/sample/model/sample.go`

```go
package model
Expand Down Expand Up @@ -206,7 +206,7 @@ func (*Sample) EnsureIndexes(db mongo.Database) {
```

#### Notes: The Model implements the interface
arch/mongo/database
`arch/mongo/database`

```golang
type Document[T any] interface {
Expand All @@ -217,7 +217,7 @@ type Document[T any] interface {
```

## DTO
api/sample/model/create_sample.go
`api/sample/dto/create_sample.go`

```go
package dto
Expand Down Expand Up @@ -261,8 +261,9 @@ func (d *InfoSample) ValidateErrors(errs validator.ValidationErrors) ([]string,
return msgs, nil
}
```

#### Notes: The DTO implements the interface
arch/network/interfaces.go
`arch/network/interfaces.go`

```golang
type Dto[T any] interface {
Expand All @@ -272,7 +273,7 @@ type Dto[T any] interface {
```

## Service
api/sample/model/service.go
`api/sample/service.go`

```go
package sample
Expand Down Expand Up @@ -318,7 +319,7 @@ func (s *service) FindSample(id primitive.ObjectID) (*model.Sample, error) {
```

#### Notes: The Service embeds the interface
arch/network/interfaces.go
`arch/network/interfaces.go`

```golang
type BaseService interface {
Expand All @@ -330,7 +331,7 @@ type BaseService interface {
- Redis Cache: `redis.Cache[dto.InfoSample]` provide the methods to make common redis queries for the DTO `dto.InfoSample`

## Controller
api/sample/model/service.go
`api/sample/controller.go`

```go
package sample
Expand Down Expand Up @@ -388,8 +389,9 @@ func (c *controller) getSampleHandler(ctx *gin.Context) {
c.Send(ctx).SuccessDataResponse("success", data)
}
```

#### Notes: The Controller implements the interface
arch/network/interfaces.go
`arch/network/interfaces.go`

```golang
type Controller interface {
Expand Down Expand Up @@ -421,8 +423,8 @@ type SendResponse interface {
}
```

## Adding Controller In Module
startup/module.go
## Enable Controller In Module
`startup/module.go`

```go
import (
Expand All @@ -441,7 +443,7 @@ func (m *module) Controllers() []network.Controller {
```

## Indexing (If Needed)
startup/indexes.go
`startup/indexes.go`

```go
import (
Expand All @@ -455,13 +457,13 @@ func EnsureDbIndexes(db mongo.Database) {
}
```

# Find this project useful ? :heart:
## Find this project useful ? :heart:
* Support it by clicking the :star: button on the upper right of this page. :v:

# More on YouTube channel - Unusual Code
## More on YouTube channel - Unusual Code
Subscribe to the YouTube channel `UnusualCode` for understanding the concepts used in this project:

[![YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@unusualcode)

# Contribution
## Contribution
Please feel free to fork it and open a PR.

0 comments on commit 1588823

Please sign in to comment.