Skip to content

Commit

Permalink
Merge pull request #22 from tayyebi/patch-1
Browse files Browse the repository at this point in the history
Added _run with docker_ method to the guide.
  • Loading branch information
hemedani authored Oct 16, 2023
2 parents 2504344 + 96c72aa commit 1a67864
Showing 1 changed file with 106 additions and 104 deletions.
210 changes: 106 additions & 104 deletions examples/simpleMircoservice/README.md
Original file line number Diff line number Diff line change
@@ -1,114 +1,116 @@
### this is just very simple microserve example
# An example of implementing a micro-service architecture

in this example we have two microserve :
Current example demonstrates two micro-services known as `core` and `ecommerce` located in directories with same naming, with basic API functionality in between.

- one named `core` which includes `user` and `country` schema with just two action know as `addCountry` and `adduser`.
- you can run this server by runnig below line on `core/` folder:
```bash
deno run -A mod.ts
```
this service respond to `HTTP POST` request to `http://localhost:8080/lesan` with this `JSON` on request body :
```bash
{
"contents": "dynamic",
"wants": {
"model": "user",
"act": "addUser"
},
"details": {
"set": {
"name": "Seyyedeh Sare Hosseini",
"address": "Iran, Hamedan",
"age": 5
},
"get": {
"age": 1,
"address": 1
}
}
## Running this example
To run each example, navigate to corresponding directories (using `cd ecommerce` or `cd core` command) and choose one of the prefered methods below:
### Method 1: OS Shell
```bash
deno run -A mod.ts
```
### Method 2: Docker container
```bash
docker run -it -v "${PWD}:/app" denoland/deno deno run --allow-all /app/mod.ts
```

The `core` microservice respond to `HTTP POST` request to `http://localhost:8080/lesan` with this `JSON` on request body mapped to its only actions defined (`addCountry` and `addUser`):
```bash
{
"contents": "dynamic",
"wants": {
"model": "user",
"act": "addUser"
},
"details": {
"set": {
"name": "Seyyedeh Sare Hosseini",
"address": "Iran, Hamedan",
"age": 5
},
"get": {
"age": 1,
"address": 1
}
```
and
```bash
{
"contents": "dynamic",
"wants": {
"model": "country",
"act": "addCountry"
},
"details": {
"set": {
"name": "iran",
"description": "Nice and great country"
},
"get": {
"name": 1
}
}
}
}
```
and
```bash
{
"contents": "dynamic",
"wants": {
"model": "country",
"act": "addCountry"
},
"details": {
"set": {
"name": "iran",
"description": "Nice and great country"
},
"get": {
"name": 1
}
```
it also can respond to `ecommerce` service request by adding `service` key to JSON body :
```bash
{
"service": "ecommerce",
"contents": "dynamic",
"wants": {
"model": "wareType",
"act": "addWareType"
}
}
```
it also can respond to `ecommerce` service request by adding `service` key to JSON body :
```bash
{
"service": "ecommerce",
"contents": "dynamic",
"wants": {
"model": "wareType",
"act": "addWareType"
},
"details": {
"set": {
"name": "digital",
"description": "digital stuff like phone and ..."
},
"details": {
"set": {
"name": "digital",
"description": "digital stuff like phone and ..."
},
"get": {
"name": 1
}
"get": {
"name": 1
}
}
```
- another named `ecommerce` which includes `ware` and `wareType` schema with two action `addWare` and `addWareType`.
- you can run this server by runnig below line on `ecommerce/` folder:
```bash
deno run -A mod.ts
```
this service respond to `HTTP POST` request to `http://localhost:8585/lesan` with this `JSON` on request body :
```bash
{
"contents": "dynamic",
"wants": {
"model": "wareType",
"act": "addWareType"
}
}
```
In the other case `ecommerce` which includes `ware` and `wareType` schema with two action `addWare` and `addWareType`.
this service respond to `HTTP POST` request to `http://localhost:8585/lesan` with this `JSON` on request body :
```bash
{
"contents": "dynamic",
"wants": {
"model": "wareType",
"act": "addWareType"
},
"details": {
"set": {
"name": "digital",
"description": "digital stuff like phone and ..."
},
"details": {
"set": {
"name": "digital",
"description": "digital stuff like phone and ..."
},
"get": {
"name": 1
}
"get": {
"name": 1
}
}
```
and
```bash
{
"contents": "dynamic",
"wants": {
"model": "ware",
"act": "addWare"
}
}
```
and
```bash
{
"contents": "dynamic",
"wants": {
"model": "ware",
"act": "addWare"
},
"details": {
"set": {
"name": "GLX phone",
"brand": "GLX",
"price": 159
},
"details": {
"set": {
"name": "GLX phone",
"brand": "GLX",
"price": 159
},
"get": {
"name": 1
"price": 1
}
"get": {
"name": 1
"price": 1
}
}
```
}
}
```

0 comments on commit 1a67864

Please sign in to comment.