Skip to content

Commit

Permalink
Add changelog and update docs for v8.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
255kb committed Aug 6, 2024
1 parent 97c7f72 commit c28abc0
Show file tree
Hide file tree
Showing 60 changed files with 233 additions and 33 deletions.
2 changes: 1 addition & 1 deletion components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const Footer: FunctionComponent<{
</li>
<li className='mb-2'>
{/* Do not use <Link>, as routes with a dot inside get rewritten without trailing slash */}
<a href='/releases/8.3.0/' className='text-reset'>
<a href='/releases/8.4.0/' className='text-reset'>
Releases
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion components/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const Nav: FunctionComponent = function () {
Blog
</Link>
<a
href='/releases/8.3.0/'
href='/releases/8.4.0/'
className={`dropdown-item ${
router.pathname === '/releases' ||
router.pathname === '/releases/[version]'
Expand Down
2 changes: 1 addition & 1 deletion content/docs/latest/api-endpoints/crud-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Mockoon will automatically translate a CRUD endpoint to multiple routes allowing
## Customizing the "id" property

By default, CRUD endpoints will use the `id` property to identify objects in an array in all the routes manipulating a single resource (e.g. GET `/resource/:id`). However, you can change this property to anything you want, like `uuid`, `custom_id`, etc:
By default, CRUD endpoints will use the `id` property to identify objects in an array in all the routes manipulating a single resource (e.g. GET `/resource/:id`). However, you can change this property to anything you want, like `uuid`, `custom_id`, etc. The crud key also supports the dot notation, allowing you to perform CRUD operations based on nested properties (e.g. `data.id`).

![Customize the CRUD id property{1484x334}](docs-img:customize-crud-id-property-key.png)

Expand Down
2 changes: 1 addition & 1 deletion content/docs/latest/api-endpoints/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ To pass arrays and objects in the query string of a request, you must use the fo

You can **disable a route** by clicking on the **Toggle route** entry in the route dropdown menu. The route will be marked with a red border and will not be accessible until you enable it again.

![disable route entry in the route dropdown menu{647x322}](docs-img:route-menu-disable-route.png)
![disable route entry in the route dropdown menu{651x322}](docs-img:route-menu-disable-route.png)

You can also disable all routes in a folder by using the **Toggle direct child routes** entry in the folder dropdown menu.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Since [v1.16.0](https://github.com/mockoon/mockoon/releases/tag/v1.16.0), Mockoo

You can locate the folder in which the API data are stored by right-clicking on each environment and selecting **"Show data file in explorer/finder"**:

![click on show in folder in the context menu{547x349}](docs-img:environment-show-in-folder.png)
![click on show in folder in the context menu{551x380}](docs-img:environment-show-in-folder.png)

## Moving the files

You can move the data files to another folder by right-clicking on an environment and selecting **"Move data file to folder"**:

![click on Move data file to folder in folder in the context menu{547x380}](docs-img:environment-move-to-folder.png)
![click on Move data file to folder in folder in the context menu{551x411}](docs-img:environment-move-to-folder.png)

> 💡 Please note that the environment file will be copied to the new folder, and the original file will **not** be deleted. If you want to delete the original file, you will have to do it manually.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ order: 1120

To copy a specific environment or route's JSON data to the clipboard, right-click on the environment or route and select **Copy to clipboard (JSON)**:

![Right click on an environment and click on Copy to clipboard (JSON){747x368}](docs-img:export-clipboard-env.png)
![Right click on an environment and click on Copy to clipboard (JSON){751x399}](docs-img:export-clipboard-env.png)

The resulting JSON can be saved in a file and directly opened in the desktop app or used with the CLI.

Expand Down
2 changes: 1 addition & 1 deletion content/docs/latest/response-configuration/file-serving.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To serve a file, you must provide a path in the file input field:

You can either provide an absolute path like `/home/username/file.json` or a relative path. Starting with [v1.16.0](https://github.com/mockoon/mockoon/releases/tag/v1.16.0), relative paths are resolved from the environment's file location. You can check the environment's file location by right-clicking on an environment en select "Show in folder" in the contextual menu:

![show in folder menu entry{547x349}](docs-img:environment-show-in-folder.png)
![show in folder menu entry{551x380}](docs-img:environment-show-in-folder.png)

> 💡 Prior to v1.16.0, relative file paths were resolved from the application executable. This is also supported by the CLI since its version [1.2.0](https://github.com/mockoon/cli/releases/tag/v1.2.0).
Expand Down
4 changes: 3 additions & 1 deletion content/docs/latest/route-responses/dynamic-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ In the dropdown menu you can choose between:

![Rule property{1177x204}](docs-img:route-response-rules-property.png)

Depending on the **target**, the way to access properties may be different:
This field supports [templating helpers](docs:templating/overview) to dynamically target a specific body property, header name, etc. Depending on the **target**, the way to access properties may be different:

- **request body**:
- keep empty to match against the full raw body content.
Expand All @@ -89,6 +89,8 @@ For **body** and **query string**, if the property is an array, Mockoon will aut

> 🛠️ Use our online [JSONPath and object-path evaluator](/tools/json-object-path-evaluator/) to test your JSONPath or object-path syntaxes and view the results in real-time.
> 💡 The **response rule values also support templating helpers** to create dynamic rules. See the [templating helpers](docs:templating/overview) documentation for more information.
### 3. Invert operator

You can invert the **comparison operator** (**!** equals, **!** regex match, etc.) by toggling on the exclamation mark button:
Expand Down
2 changes: 1 addition & 1 deletion content/docs/latest/templating/fakerjs-helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Faker.js helpers
meta:
title: Create dynamic responses with templating Faker.js helpers
description: Create realistic mock data for your mock API servers with Mockoon's templating system including Faker.js
order: 504
order: 506
---

# Faker.js helpers
Expand Down
65 changes: 65 additions & 0 deletions content/docs/latest/templating/jwt-helpers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: JWT helpers
meta:
title: Create dynamic responses with templating helpers
description: "Create dynamic fake data for your mock server with Mockoon's templating helpers. All formats are supported: JSON, CSV, HTML, etc."
order: 503
---

# JWT helpers

---

Mockoon [templating system](docs:templating/overview) includes various helpers to help you create dynamic responses. This page lists the helpers related to JWT tokens.

## jwtPayload

Extract a property from a JWT token's payload. The full token must be passed as the first argument. It will automatically ignore the `Bearer ` prefix if present, to make it easier to use it with the `Authorization` header.
If no property is passed, the full payload object will be returned to be used with other helpers like `lookup`.

| Arguments (ordered) | Type | Description |
| ------------------- | ------ | ----------- |
| 0 | string | JWT token |
| 1 | string | Property |

**Examples**

```handlebars
<!-- Returns the full payload object -->
{{jwtPayload 'abcd...'}}
<!-- Returns the 'sub' property using lookup -->
{{lookup (jwtPayload 'abcd...') 'sub'}}
<!-- Returns the 'sub' property -->
{{jwtPayload 'abcd...' 'sub'}}
<!-- Use with header helper (no need to remove 'Bearer ' from the header content) -->
{{jwtPayload (header 'Authorization') 'sub'}}
```

## jwtHeader

Extract a property from a JWT token's header. The full token must be passed as the first argument. It will automatically ignore the `Bearer ` prefix if present, to make it easier to use it with the `Authorization` header.
If no property is passed, the full header object will be returned to be used with other helpers like `lookup`.

| Arguments (ordered) | Type | Description |
| ------------------- | ------ | ----------- |
| 0 | string | JWT token |
| 1 | string | Property |

**Examples**

```handlebars
<!-- Returns the full payload object -->
{{jwtHeader 'abcd...'}}
<!-- Returns the 'alg' property using lookup -->
{{lookup (jwtHeader 'abcd...') 'alg'}}
<!-- Returns the 'alg' property -->
{{jwtHeader 'abcd...' 'alg'}}
<!-- Use with header helper (no need to remove 'Bearer ' from the header content) -->
{{jwtHeader (header 'Authorization') 'alg'}}
```
2 changes: 1 addition & 1 deletion content/docs/latest/templating/mockoon-response-helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Response helpers
meta:
title: Dynamically customize your response with templating helpers
description: "Dynamically customize your mock environments response with Mockoon's templating response helpers. All formats are supported: JSON, CSV, HTML, etc."
order: 503
order: 504
---

# Templating response helpers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Variables helpers
meta:
title: Dynamically customize your responses with variables templating helpers
description: "Dynamically customize your mock environments response with Mockoon's templating variables helpers. All formats are supported: JSON, CSV, HTML, etc."
order: 503
order: 505
---

# Templating variables helpers
Expand Down
6 changes: 3 additions & 3 deletions content/docs/latest/templating/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ order: 500

---

Mockoon implements [Handlebars](https://handlebarsjs.com/), [Faker.js v8.1.0](https://fakerjs.dev/), and a set of custom helpers to create dynamic responses. This templating system is supported in the [**data buckets**](#content-of-a-data-bucket), [**response's body**](#body-and-file-content-templating), [**header values**](#headers-and-rule-values), [**file content**](#body-and-file-content-templating), [**file path**](#file-input-templating) and [**rule values**](#headers-and-rule-values). You will find below a global overview of how and where you can use helpers. You can also check the [available helpers](#available-helpers) on specific documentation pages.
Mockoon implements [Handlebars](https://handlebarsjs.com/), [Faker.js v8.1.0](https://fakerjs.dev/), and a set of custom helpers to create dynamic responses. This templating system is supported in the [**data buckets**](#content-of-a-data-bucket), [**response's body**](#body-and-file-content-templating), [**header**](#headers-and-rule), [**file content**](#body-and-file-content-templating), [**file path**](#file-input-templating) and [**rule**](#headers-and-rule). You will find below a global overview of how and where you can use helpers. You can also check the [available helpers](#available-helpers) on specific documentation pages.

## Helpers

Expand Down Expand Up @@ -191,12 +191,12 @@ If you call this route with `/myroute/1`, `./file1.json` will be sent.

> For more information about absolute and relative file paths, please refer to our [file serving](docs:response-configuration/file-serving#absolute-or-relative-paths) documentation.
### Headers and rule values
### Headers and rule

Templating helpers can also be used in the **headers values** both in route headers and environment headers:

![add a templating helper in the header value{1174x244}](docs-img:headers-templating.png)

Finally, templating helpers can be used in the response **rule values** to create dynamic rules:

![screenshot showing a response rule with a template helper in the value field{1167x164}](docs-img:template-helper-response-rule-value.png)
![screenshot showing a response rule with a template helper in the value field{1167x154}](docs-img:template-helper-response-rule-value.png)
115 changes: 115 additions & 0 deletions content/releases/8.4.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
meta:
title: Mockoon release v8.4.0
description: Discover Mockoon applications new v8.4.0 release with templating support in rules property/path, new JWT templating helpers, dot notation support in the CRUD route key, random latencies, and many more improvements and fixes.
date: '2024-08-05'
---

Welcome to this new release of Mockoon. It brings new exciting features: **templating support in rules property/path**, **new JWT templating helpers**, **dot notation support in the CRUD route key**, **random latencies**, and many more improvements and fixes.
Read on to learn more about this release.

---

## Our sponsors

[![GitHub](https://mockoon.com/images/sponsors/github.png)](https://github.blog/2023-04-12-github-accelerator-our-first-cohort-and-whats-next/)
[![Localazy](https://mockoon.com/images/sponsors/localazy.png)](https://localazy.com/register?ref=a9CiDC61gOac-azO)

Mockoon is an open-source project built by volunteer maintainers. If you like our application, please consider sponsoring us and join all the [Sponsors and Backers](https://github.com/mockoon/mockoon/blob/main/backers.md) who helped this project over time!

[![sponsor button](https://mockoon.com/images/sponsor-btn-250.png?)](https://github.com/sponsors/mockoon)

---

## Templating support in rules property/path

**Templating helpers** are now available in the **response rules property or path field**. You can dynamically target a specific body property, header name, etc. using templating helpers:

![rules target with template helper{1071x176}](/images/releases/8.4.0/templating-support-in-rules-target.png)

[Response rules documentation](https://mockoon.com/docs/latest/route-responses/dynamic-rules/#2-property-name-or-path)

(Issue [#1443](https://github.com/mockoon/mockoon/issues/1443))

## New JWT templating helpers

Two new templating helpers are now available to help you **decode JWT tokens** in your responses: `jwtPayload` and `jwtHeader`. They let you access the **payload** and **header** objects respectively. These helpers are compatible with other templating helpers like `header`. They will also automatically ignore the `Bearer ` prefix if present in the provided string, to make it easier to use them with an `Authorization` header.

```handlebars
{{jwtPayload 'abcd...' 'sub'}}
{{jwtHeader 'abcd...' 'alg'}}
{{jwtPayload (header 'Authorization') 'sub'}}
{{jwtHeader (header 'Authorization') 'alg'}}
```

Check the [helpers documentation](https://mockoon.com/docs/latest/templating/jwt-helpers/) for more information.

(Issue [#774](https://github.com/mockoon/mockoon/issues/774))

## Dot notation support in the CRUD route's key

CRUD route key now supports **dot notation**. It allows you to perform CRUD operations (e.g. get by id, update by id, etc.) based on nested properties:

```json
{
"data": {
"id": 1
}
}
```

![CRUD route key with property containing a dot{1072x211}](/images/releases/8.4.0/dot-notation-in-crud-route-key.png)

[CRUD routes documentation](https://mockoon.com/docs/latest/api-endpoints/crud-routes/)

(Issue [#1433](https://github.com/mockoon/mockoon/issues/1433))

## Random latencies

You can now **randomize the latency** of your route responses and environments. This feature is useful to simulate network latency variations and test your application's behavior under different network conditions.
It will randomize the latency of the response **between 0 and the value you set** in the environment or route parameters.

The option can be found in the application settings:

![Random latency settings{801x908}](/images/releases/8.4.0/random-latency-settings.png)

Options are also available in the [CLI](https://github.com/mockoon/mockoon/tree/main/packages/cli), in the form of a flag `--enable-random-latency`, and in the [serverless package](https://github.com/mockoon/mockoon/tree/main/packages/serverless), in the form of a new `enableRandomLatency` option:

```javascript
const mockoonServerless = new mockoon.MockoonServerless(mockEnv, {
enableRandomLatency: true
});
```

(Issue [#568](https://github.com/mockoon/mockoon/issues/568))

## Logs timestamp improvement

In the logs tab, the logs timestamps are now displayed in a human-readable format like `7 hours ago` instead of `2024-01-01 08:00:00.123`.

![Human-readable logs timestamps{624x175}](/images/releases/8.4.0/human-readable-logs-timestamps.png)

(Issue [#1430](https://github.com/mockoon/mockoon/issues/1430))

## Mockoon Cloud desktop application improvements

- Custom scheme based authentication in the desktop application was replaced by a callback-based flow. (Issue [#1463](https://github.com/mockoon/mockoon/issues/1463))
- Fixed account downgrading not updating the running instances list. (Issue [#1461](https://github.com/mockoon/mockoon/issues/1461))
- Automatically refresh the instances list when opening the instances management dialog: (Issue [#1478](https://github.com/mockoon/mockoon/issues/1478))

## Fixes

- Last opened environment is now correctly saved after opening. (Issue [#1404](https://github.com/mockoon/mockoon/issues/1404))
- Fixed a null pointer when the last saved environment was deleted. (Issue [#1459](https://github.com/mockoon/mockoon/issues/1459))

## Chores

We updated the libraries and applications dependencies to their latest versions to fix some reported vulnerabilities.

### Thank you

A big thank you to the following people who helped to make Mockoon better:

- [@impeas](https://github.com/impeas): Random latency support. (Issue [#568](https://github.com/mockoon/mockoon/issues/568))
- [@TCezarRod](https://github.com/TCezarRod): Oclif dependencies update. (Issue [#1469](https://github.com/mockoon/mockoon/issues/1469))
Loading

0 comments on commit c28abc0

Please sign in to comment.