Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session 7 changes #4

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ Everything discussed in the Twitch live sessions for MuleSoft beginners.

## 🗓️ Next session

The next session is scheduled for `July 26, 2023` at `1:30pm ET`.

- Continue with the implementation for the rest of the resources
- Making sure the IDs are unique
- Handle errors (not just happy path)
- Create writers, categories, etc. from POST/articles when needed
- Deploy API to CloudHub - manually
- Runtime Manager
The next session is scheduled for `Aug 2, 2023` at `1:30pm ET`.

- API Manager
- CI/CD with GitHub Actions
- Maven
- Secured/encrypted properties

---

Expand All @@ -32,6 +29,7 @@ The next session is scheduled for `July 26, 2023` at `1:30pm ET`.
| 4 | Test & Publish the API Spec | We tested the API Specification using the mocking service in Design Center and adjusted a few things we had to change. Then, we published the API Spec to Exchange. Finally, we created a new Mule project from the published asset. More info [here](https://medium.com/another-integration-blog/mulesoft-from-start-a-beginners-guide-session-4-test-publish-the-api-specification-7dcca81e0b07). | [Full video (1h10m)](https://www.twitch.tv/videos/1858212063) | [Edited video (27min)](https://youtu.be/ho5GQJD8Hxo)
| 5 | Develop the API in Anypoint Studio | We created a new Mule project with the scaffolded flows from the published API specification and started our API implementation / development. More info [here](https://medium.com/another-integration-blog/mulesoft-from-start-a-beginners-guide-session-5-develop-the-api-in-anypoint-studio-a7dcfc43655c). | [Full video (1h19m)](https://www.twitch.tv/videos/1864154096) | [Edited video (37m)](https://youtu.be/K9ntwKz9vds)
| 6 | Debug the Mule App in Anypoint Studio | We reviewed how to implement the articles logic, created a Postman collection with its local+dev environments, and learned how to debug our Mule application. More info [here](https://medium.com/another-integration-blog/mulesoft-from-start-a-beginners-guide-session-6-debug-the-mule-app-in-anypoint-studio-ab7602d5b788). | [Full video (1h)](https://www.twitch.tv/videos/1876220306) | [Edited video (39m)](https://youtu.be/75IJ1WFa9iA)
| 7 | Deploy the Mule App to CloudHub (Runtime Manager) | We confirmed the API works locally, so we deployed it to CloudHub (located in Runtime Manager) to test it in the dev environment. | - [Part 1 Full video (18m)](https://www.twitch.tv/videos/1882370337) - [Part 2 Full video (1h2m)](https://www.twitch.tv/videos/1882370336) | Edited video tbd

---

Expand Down Expand Up @@ -426,22 +424,22 @@ Finish creating the rest of the requests in Postman from our API specification.
> **Note**\
> I worked on some improvements to the code's implementation before session 7. These changes were not included as session 6's homework and that's why I did not add them as part of that pull request. You can see all the improvements I did on commit [60a9813](https://github.com/alexandramartinez/mulesoft-from-start/commit/60a98133df750c094b54562db41ea7ab0ad3716d).

### ◻️ Session 7
### Session 7

- Continue with the implementation for the rest of the resources
- Making sure the IDs are unique
- Handle errors (not just happy path)
- Create writers, categories, etc. from POST/articles when needed
- Deploy API to CloudHub - manually
- Runtime Manager
- API Manager
<details>
<summary>Deploy the Mule App to CloudHub</summary>

- We learned how to deploy the Mule app to CloudHub manually from Anypoint Studio
- We learned the UI of Runtime Manager

</details>

### ◻️ Session 8

- API Manager
- CI/CD with GitHub Actions
- Maven
- Secured/encrypted properties
- DataWeave

### ◻️ Session 9

Expand Down
49 changes: 49 additions & 0 deletions sessions/7/in-session-mule-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ------------------------------------------------------------------------------ #
# Java defaults (https://github.com/github/gitignore/blob/master/Java.gitignore) #
# ------------------------------------------------------------------------------ #
*.class

# Package Files #
*.jar
*.war
*.ear

# ------------------------------------------------------------------------------------------- #
# Eclipse-specific (https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore) #
# ------------------------------------------------------------------------------------------- #
*.pydevproject
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
# local.properties
.settings/
.loadpath
.project
.classpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath

# --------------- #
# Studio-specific #
# --------------- #
target/
.mule/
.DS_Store
velocity.log
src/main/resources/application-types.xml
src/main/resources/weave
Empty file.
3 changes: 3 additions & 0 deletions sessions/7/in-session-mule-project/mule-artifact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"minMuleVersion": "4.4.0"
}
100 changes: 100 additions & 0 deletions sessions/7/in-session-mule-project/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mycompany</groupId>
<artifactId>maxines-blog</artifactId>
<version>1.0.3</version>
<packaging>mule-application</packaging>

<name>maxines-blog</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<app.runtime>4.4.0-20230320</app.runtime>
<mule.maven.plugin.version>3.8.2</mule.maven.plugin.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<classifier>---- select project type ----</classifier>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-http-connector</artifactId>
<version>1.7.3</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-sockets-connector</artifactId>
<version>1.2.3</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-apikit-module</artifactId>
<version>1.8.2</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-objectstore-connector</artifactId>
<version>1.2.1</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>4ff8cd06-fff6-4ccb-8ac0-a74161c96108</groupId>
<artifactId>maxines-blog-api</artifactId>
<version>1.0.3</version>
<classifier>raml</classifier>
<type>zip</type>
</dependency>
</dependencies>

<repositories>
<repository>
<id>anypoint-exchange-v3</id>
<name>Anypoint Exchange</name>
<url>https://maven.anypoint.mulesoft.com/api/v3/maven</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>https://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<layout>default</layout>
<url>https://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

</project>
19 changes: 19 additions & 0 deletions sessions/7/in-session-mule-project/src/main/mule/common.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<sub-flow name="common:check-404" doc:id="9451f4ad-fe7d-41fd-89e1-8f7196cd3ad7" >
<choice doc:name="Choice" doc:id="cd4ee036-ab1d-45d9-8ea1-d5193584fbb7" >
<when expression="#[isEmpty(payload)]">
<set-variable value="#[404]" doc:name="httpStatus = 404" doc:id="5b50dbbe-60fd-4fd8-9bfa-144993bcb40a" variableName="httpStatus"/>
<set-variable value="The ID you're using to retrieve information does not exist. Try a different ID!" doc:name="errorDescription" doc:id="5ecc9556-e2c6-4d31-b009-af34f3cc3122" variableName="errorDescription"/>
<raise-error doc:name="NOT_FOUND" doc:id="9bdd8be6-dbff-4133-8f9d-d0fbe222e839" type="CUSTOM:NOT_FOUND"/>
</when>
<otherwise >
<logger level="INFO" doc:name="Logger" doc:id="f5e5f2df-c89d-4e88-b120-74cba9ff490d" message="Not an empty payload"/>
</otherwise>
</choice>
</sub-flow>
</mule>
11 changes: 11 additions & 0 deletions sessions/7/in-session-mule-project/src/main/mule/global.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit="http://www.mulesoft.org/schema/mule/mule-apikit" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:os="http://www.mulesoft.org/schema/mule/os" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/mule-apikit http://www.mulesoft.org/schema/mule/mule-apikit/current/mule-apikit.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/os http://www.mulesoft.org/schema/mule/os/current/mule-os.xsd">
<http:listener-config name="maxines-blog-api-httpListenerConfig">
<http:listener-connection host="${http.host}" port="${http.port}" />
</http:listener-config>
<apikit:config name="maxines-blog-api-config" api="resource::4ff8cd06-fff6-4ccb-8ac0-a74161c96108:maxines-blog-api:1.0.3:raml:zip:maxines-blog-api.raml" outboundHeadersMapName="outboundHeaders" httpStatusVarName="httpStatus" />
<global-property doc:name="Global Property" doc:id="88a33def-4655-439d-a5bd-e5d30b04bd57" name="env" value="local" />
<configuration-properties doc:name="Configuration properties" doc:id="8a21399f-73af-4da1-bc58-3dc54676d6a5" file="${env}.properties" />
<os:object-store name="Object_store" doc:name="Object store" doc:id="7a532520-e076-42ea-b5d9-7832f470b968" />
<configuration-properties doc:name="Configuration properties" doc:id="b3504d8f-cec4-437a-9420-80c0d2f1caf9" file="default.properties" />
</mule>
104 changes: 104 additions & 0 deletions sessions/7/in-session-mule-project/src/main/mule/maxines-blog-api.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit="http://www.mulesoft.org/schema/mule/mule-apikit" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:os="http://www.mulesoft.org/schema/mule/os" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/mule-apikit http://www.mulesoft.org/schema/mule/mule-apikit/current/mule-apikit.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/os http://www.mulesoft.org/schema/mule/os/current/mule-os.xsd">
<flow name="maxines-blog-api-main">
<http:listener config-ref="maxines-blog-api-httpListenerConfig" path="/api/*">
<http:response statusCode="#[vars.httpStatus default 200]">
<http:headers><![CDATA[#[vars.outboundHeaders default {}]]]></http:headers>
</http:response>
<http:error-response statusCode="#[vars.httpStatus default 500]">
<http:body><![CDATA[#[%dw 2.0
output application/json
var descriptions = {
"400": "There's something wrong with your request. Please review it before resending.",
"404": "This resource was not found or does not exist.",
"405": "The method you're using in your request is not allowed in this API.",
"406": "Not acceptable.",
"415": "Your request is on an unsupported media type. Please use JSON.",
"501": "This API does not support what you're trying to do!"
}
var httpStatus = vars.httpStatus as String
---
{
code: vars.httpStatus,
description: if (isEmpty(vars.errorDescription)) descriptions[httpStatus] else vars.errorDescription
}]]]></http:body>
<http:headers><![CDATA[#[vars.outboundHeaders default {}]]]></http:headers>
</http:error-response>
</http:listener>
<apikit:router config-ref="maxines-blog-api-config" />
<error-handler>
<on-error-propagate type="APIKIT:BAD_REQUEST">
<set-variable value="#[400]" doc:name="httpStatus 400" doc:id="24702fe0-de9c-4767-9a34-bcd641aa197f" variableName="httpStatus"/>
</on-error-propagate>
<on-error-propagate type="APIKIT:NOT_FOUND">
<set-variable value="#[404]" doc:name="httpStatus 404" doc:id="59ccc86c-b64e-4b5e-9271-90e81c848f09" variableName="httpStatus"/>
</on-error-propagate>
<on-error-propagate type="APIKIT:METHOD_NOT_ALLOWED">
<set-variable value="#[405]" doc:name="httpStatus 405" doc:id="25385331-662b-4191-8601-a06c53a44924" variableName="httpStatus"/>
</on-error-propagate>
<on-error-propagate type="APIKIT:NOT_ACCEPTABLE">
<set-variable value="#[406]" doc:name="httpStatus 406" doc:id="051751f1-2c6a-4b67-b958-93e9450e2e35" variableName="httpStatus"/>
</on-error-propagate>
<on-error-propagate type="APIKIT:UNSUPPORTED_MEDIA_TYPE">
<set-variable value="#[415]" doc:name="httpStatus 415" doc:id="8d525eff-ec3b-49c3-b98f-5ae0b67a7ff9" variableName="httpStatus"/>
</on-error-propagate>
<on-error-propagate type="APIKIT:NOT_IMPLEMENTED">
<set-variable value="#[501]" doc:name="httpStatus 501" doc:id="ae28fc56-ff91-4e63-9c9f-4c7580202f3e" variableName="httpStatus"/>
</on-error-propagate>
</error-handler>
</flow>
<flow name="put:\articles\(articleId):application\json:maxines-blog-api-config">
<flow-ref doc:name="update one article" doc:id="c9ce24c0-503d-44ae-a1a7-f096383be773" name="resources-articles:update-one-article"/>
</flow>
<flow name="put:\articles\(articleId)\comments\(commentId):application\json:maxines-blog-api-config">
<flow-ref doc:name="update one comment from an article" doc:id="9d7ff7ec-2c1a-4923-865c-09c774f860ee" name="resources-comments:update-one-comment-from-an-article"/>
</flow>
<flow name="put:\writers\(writerId):application\json:maxines-blog-api-config">
<flow-ref doc:name="update one writer" doc:id="ba516463-ed27-4624-8240-5bef17f5a216" name="resources-writers:update-one-writer"/>
</flow>
<flow name="delete:\articles\(articleId):maxines-blog-api-config">
<flow-ref doc:name="delete one article" doc:id="5737bc13-e19d-46e5-9711-3b55413cd682" name="resources-articles:delete-one-article"/>
</flow>
<flow name="delete:\articles\(articleId)\comments\(commentId):maxines-blog-api-config">
<flow-ref doc:name="delete one comment from an article" doc:id="b7adcb4d-1b1f-48c3-840d-2b2c7e6ec2eb" name="resources-comments:delete-one-comment-from-an-article"/>
</flow>
<flow name="delete:\writers\(writerId):maxines-blog-api-config">
<flow-ref doc:name="delete one writer" doc:id="e7979ba2-047d-432c-bc0e-699fe5d806be" name="resources-writers:delete-one-writer"/>
</flow>
<flow name="get:\categories:maxines-blog-api-config">
<flow-ref doc:name="read categories" doc:id="b45f67fe-b9f5-41ea-afe0-5261b9772aa0" name="resources-categories:read-categories"/>
</flow>
<flow name="get:\articles:maxines-blog-api-config">
<flow-ref doc:name="read all articles" doc:id="b4e85e5b-af6a-4f96-94f6-3cd5fc671580" name="resources-articles:read-all-articles"/>
</flow>
<flow name="get:\articles\(articleId)\comments:maxines-blog-api-config">
<flow-ref doc:name="read all comments from an article" doc:id="153c9bbb-886e-4324-bf6c-3a3908c76289" name="resources-comments:read-all-comments-from-an-article"/>
</flow>
<flow name="get:\writers:maxines-blog-api-config">
<flow-ref doc:name="read all writers" doc:id="bc9cff90-90f0-4a8a-ba4f-22cddf206039" name="resources-writers:read-all-writers"/>
</flow>
<flow name="get:\articles\(articleId):maxines-blog-api-config">
<flow-ref doc:name="read one article" doc:id="42a75635-84c0-4c1e-8f47-7ea2c9daa2e7" name="resources-articles:read-one-article"/>
</flow>
<flow name="get:\articles\(articleId)\comments\(commentId):maxines-blog-api-config">
<flow-ref doc:name="read one comment from an article" doc:id="aa9248b5-417f-4c5c-92d4-87b8f60f3aa0" name="resources-comments:read-one-comment-from-an-article"/>
</flow>
<flow name="get:\writers\(writerId):maxines-blog-api-config">
<flow-ref doc:name="read one writer" doc:id="ba449337-9697-4e69-b21d-0a25f8abf361" name="resources-writers:read-one-writer"/>
</flow>
<flow name="post:\articles:application\json:maxines-blog-api-config">
<flow-ref doc:name="create one article" doc:id="792952ad-33ac-4238-bdc2-0c2d2099b070" name="resources-articles:create-one-article"/>
</flow>
<flow name="post:\articles\(articleId)\comments:application\json:maxines-blog-api-config">
<flow-ref doc:name="create one comment in an article" doc:id="573bc752-b8da-482d-8497-809da199572e" name="resources-comments:create-one-comment-in-an-article"/>
</flow>
<flow name="post:\writers:application\json:maxines-blog-api-config">
<flow-ref doc:name="create one writer" doc:id="6cbff407-3715-4683-8343-03496636c5e6" name="resources-writers:create-one-writer"/>
</flow>
<flow name="delete:\categories:application\json:maxines-blog-api-config">
<flow-ref doc:name="delete categories" doc:id="41e4801c-d67e-4c30-a441-84af03a7dc2d" name="resources-categories:delete-categories"/>
</flow>
<flow name="post:\categories:application\json:maxines-blog-api-config">
<flow-ref doc:name="create or update categories" doc:id="86547df6-5091-4dff-8970-52199feab48c" name="resources-categories:create-or-update-categories"/>
</flow>
</mule>
Loading