Skip to content

Commit ee38f2d

Browse files
committed
restored next
Signed-off-by: Matteo Collina <hello@matteocollina.com>
1 parent 663bb1f commit ee38f2d

61 files changed

Lines changed: 1001 additions & 3084 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/cli.md

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ Welcome to Platformatic. Available commands are:
9090
* `logs` - stream logs for a Platformatic runtime application.
9191
* `upgrade` - upgrade the Platformatic configuration to the latest version.
9292
* `resolve` - resolve Platformatic Runtime external services
93-
* `patch-config` - Applies a patch file to the runtime and services configurations.
9493
* `client` - generate a Platformatic client.
9594
* `build` - builds all services.
9695
* `install` - install all dependencies of an application and its services.
@@ -144,6 +143,20 @@ To get the list of runtimes with enabled management API use the
144143
`platformatic ctl ps` command.
145144

146145

146+
#### install
147+
148+
Install all dependencies of an application and its services.
149+
150+
```bash
151+
platformatic install
152+
```
153+
154+
Options:
155+
156+
* `-p, --production`: Only install production dependencies.
157+
* `-P, --package-manager EXECUTABLE`: Use an alternative package manager (the default is to autodetect it).
158+
159+
147160
#### logs
148161

149162
Streams logs from the platformatic runtime application.
@@ -244,15 +257,6 @@ You can find more details about the configuration format here:
244257
* [Platformatic DB Configuration](https://docs.platformatic.dev/docs/db/configuration)
245258
* [Platformatic Service Configuration](https://docs.platformatic.dev/docs/service/configuration)
246259

247-
#### `patch-config`
248-
249-
Applies a patch file to the runtime and services configurations.
250-
251-
Arguments:
252-
253-
* `-c, --config FILE` - Path to the runtime configuration file.
254-
- `-p, --patch PATCH`: The file containing the patch to execute. Its default export should be a function that receives the `runtime` and `services` arguments and returns an object containing
255-
the `runtime` and `services` keys with [JSON Patch](https://jsonpatch.com/) formatted patch to apply to configuration files.
256260

257261
#### start
258262

@@ -302,19 +306,6 @@ platformatic client <command>
302306
```
303307

304308

305-
### install
306-
307-
Install all dependencies of an application and its services.
308-
309-
```bash
310-
platformatic install
311-
```
312-
313-
Options:
314-
315-
* `-p, --production`: Only install production dependencies.
316-
* `-P, --package-manager EXECUTABLE`: Use an alternative package manager (the default is to autodetect it).
317-
318309
#### help
319310

320311
Create a Fastify plugin that exposes a client for a remote OpenAPI or GraphQL API.
@@ -400,9 +391,11 @@ Options:
400391
* `--types-only` - Generate only the type file.
401392
* `--types-comment` - Add a comment at the beginning of the auto generated `.d.ts` type definition.
402393
* `--with-credentials` - Adds "credentials: 'include'" to all fetch requests (only for frontend clients).
394+
* `--props-optional` - If `true`, properties will be defined as optional unless they're part of the `required` array. By default this option is `false`.
403395
* `--skip-config-update` - If `true`, it will not update the `platformatic|watt` config found in your repo.
404396

405397

398+
406399
### composer
407400

408401
```bash
@@ -1144,6 +1137,24 @@ To get the list of runtimes with enabled management API use the
11441137
`platformatic ctl ps` command.
11451138

11461139

1140+
#### metrics
1141+
1142+
Get metrics from the platformatic runtime application.
1143+
1144+
``` bash
1145+
$ platformatic ctl metrics
1146+
```
1147+
1148+
Options:
1149+
1150+
* `-p, --pid <number>` - The process id of the runtime.
1151+
* `-f, --format <string>` - The format of the metrics, which should be either `text` or `json` (default to `json`).
1152+
1153+
If `--pid` is not specified, the command will get metrics from the first available matching runtime.
1154+
1155+
To see the list of all available control commands, run `platformatic ctl help`.
1156+
1157+
11471158
#### ps
11481159

11491160
Lists all running platformatic runtime applications.

docs/client/frontend.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ console.log(movies)
4545

4646
You can use both named operations and the factory in the same file. They can work on different hosts, so the factory does _not_ use the global `setBaseUrl` function.
4747

48+
### Default fetch params
49+
50+
You can set additional parameters to be passed to the client `fetch` instance.
51+
52+
```js
53+
import build from './api.js'
54+
import { setDefaultFetchParams } from './api.js'
55+
56+
setDefaultFetchParams({
57+
keepalive: false,
58+
mode: 'no-cors'
59+
})
60+
61+
// `fetch` will be called with the `keepalive` and `mode` method as defined above
62+
const movies = await getMovies({})
63+
console.log(movies)
64+
```
65+
4866
### Default Headers
4967

5068
You can set headers that will be sent along with all the requests made by the client. This is useful, for instance, for authentication.
@@ -58,6 +76,7 @@ setBaseUrl('http://my-server-url.com') // modifies the global `baseUrl` variable
5876
setDefaultHeaders({
5977
authorization: 'Bearer MY_TOKEN'
6078
})
79+
6180
const movies = await getMovies({})
6281
console.log(movies)
6382
```
@@ -98,8 +117,9 @@ interface GetMoviesResponseOK {
98117
'title': string;
99118
}
100119
export interface Api {
101-
setBaseUrl(newUrl: string) : void;
102-
setDefaultHeaders(headers: Object) : void;
120+
setBaseUrl(newUrl: string): void;
121+
setDefaultHeaders(headers: Object): void;
122+
setDefaultFetchParams(fetchParams: RequestInit): void;
103123
getMovies(req: GetMoviesRequest): Promise<Array<GetMoviesResponseOK>>;
104124
// ... all operations listed here
105125
}
@@ -118,10 +138,12 @@ let defaultHeaders = ''
118138
/** @type {import('./api-types.d.ts').Api['setBaseUrl']} */
119139
export const setBaseUrl = (newUrl) => { baseUrl = newUrl }
120140

121-
122141
/** @type {import('./api-types.d.ts').Api['setDefaultHeaders']} */
123142
export const setDefaultHeaders = (headers) => { defaultHeaders = headers }
124143

144+
/** @type {import('./${name}-types.d.ts').${camelCaseName}['setDefaultFetchParams']} */
145+
export const setDefaultFetchParams = (fetchParams) => { defaultFetchParams = fetchParams }
146+
125147
/** @type {import('./api-types.d.ts').Api['getMovies']} */
126148
export const getMovies = async (request) => {
127149
return await _getMovies(baseUrl, request)
@@ -165,12 +187,15 @@ import type { Api } from './api-types'
165187
import type * as Types from './api-types'
166188

167189
let baseUrl = ''
168-
let defaultHeaders = ''
190+
let defaultHeaders = {}
191+
let defaultFetchParams = {}
169192

170193
export const setBaseUrl = (newUrl: string) : void => { baseUrl = newUrl }
171194

172195
export const setDefaultHeaders = (headers: Object) => { defaultHeaders = headers }
173196

197+
export const setDefaultFetchParams = (fetchParams: RequestInit): void => { defaultFetchParams = fetchParams }
198+
174199
const _getMovies = async (url: string, request: Types.GetMoviesRequest) => {
175200
const response = await fetch(`${url}/movies/?${new URLSearchParams(Object.entries(request || {})).toString()}`)
176201

docs/composer/programmatic.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,25 @@ const app = await buildServer({
3232
hostname: '127.0.0.1',
3333
port: 0
3434
},
35-
services: [
36-
{
37-
id: 'auth-service',
38-
origin: 'https://auth-service.com',
39-
openapi: {
40-
url: '/documentation/json',
41-
prefix: 'auth'
35+
composer: {
36+
services: [
37+
{
38+
id: 'auth-service',
39+
origin: 'https://auth-service.com',
40+
openapi: {
41+
url: '/documentation/json',
42+
prefix: 'auth'
43+
}
44+
},
45+
{
46+
id: 'payment-service',
47+
origin: 'https://payment-service.com',
48+
openapi: {
49+
file: './schemas/payment-service.json'
50+
}
4251
}
43-
},
44-
{
45-
id: 'payment-service',
46-
origin: 'https://payment-service.com',
47-
openapi: {
48-
file: './schemas/payment-service.json'
49-
}
50-
}
51-
]
52+
]
53+
}
5254
})
5355

5456
await app.start()

docs/contributing/documentation-style-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ More like this:
124124
>As an example, the following recommendations should be
125125
referenced.
126126

127-
To view a live example, refer to the [Decorators](../reference/db/configuration.md)
127+
To view a live example, refer to the [Decorators](../db/configuration.md)
128128
reference document.
129129

130130
To recap, **avoid "you" in reference documentation or API documentation.**

docs/db/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ postgres://user:password@my-database:5432/db-name
200200
```
201201

202202
You can for example add the `security` section, so that Swagger will allow you to add the authentication header to your requests.
203-
We're adding a Bearer token in the form of a [JWT](/reference/db/authorization/strategies.md#json-web-token-jwt) in the code block below:
203+
We're adding a Bearer token in the form of a [JWT](./authorization/strategies.md#json-web-token-jwt) in the code block below:
204204

205205
```json title="Example Object"
206206
{
File renamed without changes.
File renamed without changes.

docs/guides/keycloak-images/assign_service_account_roles.png renamed to docs/db/keycloak-images/assign_service_account_roles.png

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)