Skip to content

Commit

Permalink
[automated commit] Bump docs to version 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
leorossi authored and github-actions[bot] committed Oct 19, 2023
1 parent 88377de commit 227137a
Show file tree
Hide file tree
Showing 140 changed files with 124 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,47 @@ Edit your app's `platformatic.service.json` to load your root plugin:
"paths": [{
"path": "./root-plugin.js",
"encapsulate": false
}],
"hotReload": false
},
"watch": false
}]
}
}
```

These settings are important when using `@fastify/express` in a Platformatic Service app:

- `encapsulate` — You'll need to disable encapsulation for any Fastify plugin which mounts Express routes. This is due to the way that `@fastify/express` works.
- `hotReload` and `watch` — You'll need to disable hot reloading and watching for your app, as they don't currently work when using `@fastify/express`. This is a known issue that we're working to fix.

### Using @fastify/express with Platformatic Runtime

If you are using [Platformatic Runtime](/referece/runtime/introduction.md), you must configure your other services to connect to this one using an actual TCP socket
instead of the virtual network.

Edit your app's `platformatic.runtime.json` and add the `useHttp` option:

```json
{
"$schema": "https://platformatic.dev/schemas/v1.3.0/runtime",
"entrypoint": "b",
"autoload": {
"path": "./services",
"mappings": {
"myexpressservice": {
"id": "a",
"config": "platformatic.service.json",
"useHttp": true
}
}
},
"server": {
"hostname": "127.0.0.1",
"port": 3000,
"logger": {
"level": "info"
}
}
}
```

Where the Platformatic Service using express is located at `./services/myexpressservice`.

## Wrapping up

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,18 @@ To create a client for a remote Graphql API, you can use the following command:
$ platformatic client http://example.com/graphql -n myclient
```

Instead of a URL, you can also use a local file:
Instead of an URL, you can also use a local file:

```bash
$ platformatic client path/to/schema -n myclient
```

This will create a Fastify plugin that exposes a client for the remote API in a folder `myclient`
and a file named myclient.js inside it.
To create a client for a service running in a Platformatic runime use the following command:
```bash
$ platformatic client --runtime SERVICE_NAME -n myclient
```

All the above commands will create a Fastify plugin that exposes a client in the `request` object for the remote API in a folder `myclient` and a file named myclient.js inside it.

If platformatic config file is specified, it will be edited and a `clients` section will be added.
Then, in any part of your Platformatic application you can use the client.
Expand All @@ -244,7 +248,7 @@ You can use the client in your application in Javascript, calling a GraphQL endp
```js
module.exports = async function (app, opts) {
app.post('/', async (request, reply) => {
const res = await app.myclient.graphql({
const res = await request.myclient.graphql({
query: 'query { hello }'
})
return res
Expand All @@ -260,8 +264,8 @@ import { FastifyInstance } from 'fastify'
/// <reference path="./myclient" />

export default async function (app: FastifyInstance) {
app.get('/', async () => {
return app.myclient.get({})
app.get('/', async (request, reply) => {
return request.myclient.get({})
})
}
```
Expand All @@ -272,6 +276,7 @@ Options:
* `-n, --name <name>` - Name of the client.
* `-f, --folder <name>` - Name of the plugin folder, defaults to --name value.
* `-t, --typescript` - Generate the client plugin in TypeScript.
* `-R, --runtime <serviceId>` - Generate the client for the `serviceId` running in the current runtime
* `--frontend` - Generated a browser-compatible client that uses `fetch`
* `--full-response` - Client will return full response object rather than just the body.
* `--full-request` - Client will be called with all parameters wrapped in `body`, `headers` and `query` properties. Ignored if `--frontend`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ You can use the client in your application in Javascript, calling a GraphQL endp
/** @type {import('fastify').FastifyPluginAsync<{} */
module.exports = async function (app, opts) {
app.post('/', async (request, reply) => {
const res = await app.myclient.graphql({
const res = await request.myclient.graphql({
query: 'query { movies { title } }'
})
return res
Expand All @@ -48,8 +48,8 @@ import { FastifyInstance } from 'fastify'
/// <reference path="./myclient" />

export default async function (app: FastifyInstance) {
app.get('/', async () => {
return app.myclient.get({})
app.get('/', async (request, reply) => {
return requests.myclient.get({})
})
}
```
Expand Down Expand Up @@ -323,7 +323,7 @@ module.exports = async function (app, opts) {
})

app.post('/', async (request, reply) => {
const res = await app.myclient.graphql({
const res = await request.myclient.graphql({
query: 'query { movies { title } }'
})
return res
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ A **required** object with the following settings:
}
```

Enables GraphQL support with the `enabled` option

```json
{
"db": {
...
"graphql": {
...
"enabled": true
}
}
}
```

Enables GraphQL support with GraphiQL

```json
Expand Down Expand Up @@ -165,6 +179,20 @@ A **required** object with the following settings:
}
```

Enables OpenAPI using the `enabled` option

```json
{
"db": {
...
"openapi": {
...
"enabled": true
}
}
}
```

Enables OpenAPI with prefix

```json
Expand Down Expand Up @@ -252,6 +280,12 @@ A **required** object with the following settings:

- **`poolSize`** (`number`, default: `10`) — Maximum number of connections in the connection pool.

- **`idleTimeoutMilliseconds`** (`number`, default: `30000`) - Max milliseconds a client can go unused before it is removed from the pool and destroyed.

- **`queueTimeoutMilliseconds`** (`number`, default: `60000`) - Number of milliseconds to wait for a connection from the connection pool before throwing a timeout error.

- **`acquireLockTimeoutMilliseconds`** (`number`, default: `60000`) - Number of milliseconds to wait for a lock on a connection/transaction.

- **`limit`** (`object`) - Set the default and max limit for pagination. Default is 10, max is 1000.

_Examples_
Expand Down Expand Up @@ -289,6 +323,20 @@ A **required** object with the following settings:

_Examples_

Enable events using the `enabled` option.

```json
{
"db": {
...
"events": {
...
"enabled": true
}
}
}
```

```json
{
"db": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ these default values.
microservice ID.
- **`config` (**required**, `string`) - The overridden configuration file
name. This is the file that will be used when starting the microservice.
- **`useHttp`** (`boolean`) - The service will be started on a random HTTP port
on `127.0.0.1`, and exposed to the other services via that port; set it to `true`
if you are using [@fastify/express](https://github.com/fastify/fastify-express).
Default: `false`.

### `services`

Expand All @@ -83,6 +87,10 @@ property or the `name` field in the client's `package.json` file if a
the microservice.
- **`config`** (**required**, `string`) - The configuration file used to start
the microservice.
- **`useHttp`** (`boolean`) - The service will be started on a random HTTP port
on `127.0.0.1`, and exposed to the other services via that port; set it to `true`
if you are using [@fastify/express](https://github.com/fastify/fastify-express).
Default: `false`.

### `entrypoint`

Expand All @@ -103,6 +111,8 @@ While hot reloading is useful for development, it is not recommended for use in
production.
:::

Note that `watch` should be enabled for each individual service in the runtime.

### `allowCycles`

An optional boolean, defaulting to `false`, indicating if dependency cycles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ An optional object that defines the plugins loaded by Platformatic Service.
- `options` (`object`): Optional plugin options.
- `encapsulate` (`boolean`): if the path is a folder, it instruct Platformatic to not encapsulate those plugins.
- `maxDepth` (`integer`): if the path is a folder, it limits the depth to load the content from.
- `autoHooks` (`boolean`): Apply hooks from autohooks.js file(s) to plugins found in folder.
- `autoHooksPattern` (`string`): Regex to override the autohooks naming convention.
- `cascadeHooks` (`boolean`): If using autoHooks, cascade hooks to all children. Ignored if autoHooks is false.
- `overwriteHooks` (`boolean`): If using cascadeHooks, cascade will be reset when a new autohooks.js file is encountered. Ignored if autoHooks is false.
- `routeParams` (`boolean`): Folders prefixed with _ will be turned into route parameters.
- `forceESM` (`boolean`): If set to 'true' it always use await import to load plugins or hooks.
- `ignoreFilter` (`string`): Filter matching any path that should not be loaded. Can be a RegExp, a string or a function returning a boolean.
- `matchFilter` (`string`): Filter matching any path that should be loaded. Can be a RegExp, a string or a function returning a boolean.
- `ignorePattern` (`string`): RegExp matching any file or folder that should not be loaded.
- `indexPattern` (`string`): Regex to override the index.js naming convention
- **`typescript`** (`boolean` or `object`): enable TypeScript compilation. A `tsconfig.json` file is required in the same folder. See [TypeScript compilation options](#typescript-compilation-options) for more details.

_Example_
Expand All @@ -144,7 +154,7 @@ _Example_

The `typescript` can also be an object to customize the compilation. Here are the supported options:

* `enabled` (`boolean`): enables compilation
* `enabled` (`boolean` or `string`): enables compilation
* `tsConfig` (`string`): path to the `tsconfig.json` file relative to the configuration
* `outDir` (`string`): the output directory of `tsconfig.json`, in case `tsconfig.json` is not available
and and `enabled` is set to `false` (procution build)
Expand Down Expand Up @@ -173,10 +183,12 @@ Example:

### `watch`

Disable watching for file changes if set to `false`. It can also be customized with the following options:
Enables watching for file changes if set to `true` or `"true"`. It can also be customized with the following options:

* **`enabled`** (`boolean` or `string`): enables watching.
- **`ignore`** (`string[]`, default: `null`): List of glob patterns to ignore when watching for changes. If `null` or not specified, ignore rule is not applied. Ignore option doesn't work for typescript files.
- **`allow`** (`string[]`, default: `['*.js', '**/*.js']`): List of glob patterns to allow when watching for changes. If `null` or not specified, allow rule is not applied. Allow option doesn't work for typescript files.
-

_Example_

Expand Down
4 changes: 2 additions & 2 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
"1.5.1",
"1.5.0",
"1.4.1",
"1.4.0",
"1.3.1",
"1.3.0"
"1.3.1"
]

0 comments on commit 227137a

Please sign in to comment.