Skip to content

Commit

Permalink
26 subscribe service (#36)
Browse files Browse the repository at this point in the history
* 20 product variants support 

add product service and documentation
  • Loading branch information
serhiibabanov authored Jun 20, 2024
1 parent 4305469 commit fd6f56e
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 20 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/dev.yml

This file was deleted.

9 changes: 9 additions & 0 deletions .github/workflows/docs_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ jobs:
working-directory: service-products
- name: Copy generated-snippets
run: cp -rf service-products/build/generated-snippets/* docs/src/generated-snippets/
#generate and copy snippets from service-subscribe
- name: Make gradlew executable
run: chmod +x ./gradlew
working-directory: service-subscribe
- name: Execute Gradle tests
run: ./gradlew test
working-directory: service-subscribe
- name: Copy generated-snippets
run: cp -rf service-subscribe/build/generated-snippets/* docs/src/generated-snippets/
#generate docs
- name: Make gradlew executable
run: chmod +x ./gradlew
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/service_subscription_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: publish service-subscribe
on:
push:
branches: ['dev']
paths: ['service-subscribe/**']

jobs:
test_build:
runs-on: self-hosted
defaults:
run:
working-directory: service-subscribe
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: dev
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Execute Gradle build
run: ./gradlew build

docker:
needs: test_build
name: build docker image service-subscribe
runs-on: self-hosted
defaults:
run:
working-directory: service-subscribe
steps:
- name: checkout code
uses: actions/checkout@v3
with:
ref: dev

- name: Make gradlew executable
run: |
chmod +x ./gradlew
- name: Execute Gradle bootBuildImage
run: ./gradlew bootBuildImage
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image to Docker Hub
run: docker push serhiibabanov/service-subscribe:latest
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Pottery API

This is the API for the Pottery Store project. It's built with Java, Spring Boot, Kotlin, Gradle, and SQL.

## Services

The project consists of several services:

- `service-products`: Handles all operations related to products.
- `docs`: Handles the generation and serving of documentation.

## Running the Project

To run the project, use the following command:

```bash
docker compose up -d
```
This will start all the services. You can access the API through the backend-gateway service at http://localhost:8080.

Documentation
The API documentation is generated using Spring REST Docs and served by the docs service. You can access it at http://localhost:8080/docs/index.html.
8 changes: 8 additions & 0 deletions backend-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ spring:
uri: lb://docs
predicates:
- Path=/docs/**
- id: service-subscribe-id
uri: lb://service-subscribe
predicates:
- Path=/api/subscribe
- id: service-unsubscribe-id
uri: lb://service-subscribe
predicates:
- Path=/api/unsubscribe

eureka:
client:
Expand Down
14 changes: 14 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ services:
restart: on-failure
networks:
- pottery_store
service-subscribe:
image: "serhiibabanov/service-subscribe:latest"
container_name: "service-subscribe"
environment:
- DATABASE_URL=jdbc:postgresql://database:5432/potterystore
- EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://service-discovery:8761/eureka
ports:
- "8083:8083"
depends_on:
- database
- service-discovery
restart: on-failure
networks:
- pottery_store
database:
container_name: "database"
build:
Expand Down
2 changes: 2 additions & 0 deletions database-image/postgresql/init.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE ROLE service_products WITH LOGIN PASSWORD 'srv-pds';
CREATE ROLE service_subscribe WITH LOGIN PASSWORD 'srv-sbs';

CREATE SCHEMA service_products AUTHORIZATION service_products;
CREATE SCHEMA service_subscribe AUTHORIZATION service_subscribe;
3 changes: 2 additions & 1 deletion docs/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

[[abstract]]

Document RESTful services by combining hand-written documentation with auto-generated snippets produced with Spring MVC Test or WebTestClient.
Document Pottery API services by combining hand-written documentation with auto-generated snippets produced with Spring MVC Test.

include::categories.adoc[]
include::collections.adoc[]
include::materials.adoc[]
include::colors.adoc[]
include::products.adoc[]
include::subscribe.adoc[]
44 changes: 44 additions & 0 deletions docs/src/docs/asciidoc/subscribe.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[[subscription]]
= Subscription

[[subscription-index-create]]
== Subscribing users

A `POST` request is used to subscribe a user to the newsletter

=== Request structure

include::{snippets}/subscribe/http-request.adoc[]

=== Request parameters

include::{snippets}/subscribe/query-parameters.adoc[]

=== Example http response

include::{snippets}/subscribe/http-response.adoc[]

=== CURL request

include::{snippets}/subscribe/curl-request.adoc[]

[[subscription-index-unsubscribe]]
== Unsubscribing users

A `POST` request is used to unsubscribe a user from the newsletter

=== Request structure

include::{snippets}/unsubscribe/http-request.adoc[]

=== Request parameters

include::{snippets}/unsubscribe/query-parameters.adoc[]

=== Example http response

include::{snippets}/unsubscribe/http-response.adoc[]

=== CURL request

include::{snippets}/unsubscribe/curl-request.adoc[]

0 comments on commit fd6f56e

Please sign in to comment.