Skip to content

Commit

Permalink
CI: update generated docs
Browse files Browse the repository at this point in the history
 [skip ci]
  • Loading branch information
github-actions[bot] committed Jun 2, 2023
1 parent db78196 commit bbe3168
Show file tree
Hide file tree
Showing 19 changed files with 316 additions and 545 deletions.
77 changes: 1 addition & 76 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,79 +37,4 @@ A general way of authorizing requests by first validating the token and then che

1. Create an authenticator instance and pass it to routing-controllers `authorizationChecker` with [getAuthenticator](docs/modules.md#getauthenticator)
- This will connect the `@Authorize` decorator
2. Apply @Authorize decorator to a route or controller
3. Create a [Requirement](docs/modules.md#irequirement)
4. Pass one or a set of requirements to the `@Authorize` decorator
- To see how the requirements are applied, see the [authenticator documentation](docs/modules.md#getauthenticator)

### Access tokens

Applications should use short lived [JWT](https://jwt.io/) tokens to authenticate users.

papi uses a simple yet secure token mechanism. A secret is used to sign the token and the same secret is used to verify the validity of the token. Each application and environment should have it's own secret.

Creating a token is as simple as calling [createAccessToken](modules.md#createaccesstoken) with the required data and the secret that's used when [getting the authenticator](docs/modules.md#getauthenticator).

When the `@Authorize` decorator fires the token will be automatically verified and the data will be available on `request.token`

## Contracts

Contracts are the way to validate input and output. All views and bodies should be a contract with properties appropriately decorated using class-validator and class-transformer decorators.

papi comes with a set of base contracts for error handling and pagination.

- [Error classes](docs/modules.md#error-classes)
- [Contract classes](docs/modules.md#contract-classes) (Paging / Representation)

## Middleware

A set of default middleware is provided.

The full list of available middleware can be found in the [technical documentation](/docs/modules.md#middleware-functions).

## JSONSchema

Helper functions that generate a swagger schema based on views annotated with `class-validator` and `class-transformer`. Except for some small fixes, this code is copied from [epiphone/class-validator-jsonschema](https://github.com/epiphone/class-validator-jsonschema).
<br>
<br>

## Local Development

### Testing

Tests are executed on a local build. Make sure the watcher is always on by enabling `vscode > Manage Automatic Tasks in Folder > Allow Automatic Tasks in Folder`

### Connecting a referencing project with yalc

Manually install the peer dependencies for building the project:

if we want to use this package with a link / file reference
we need to install the packages
we need to install the modules from peerdependencies (**WITHOUT ADDING THEM TO PACKAGE.JSON**)
build the project
remove the node modules again
and optionally install the modules from package.json again (without the peerdependencies in the node modules)

<https://github.com/yarnpkg/yarn/issues/8105>
<https://github.com/typestack/class-transformer/issues/384>
<https://blog.thinknum.com/common-pitfalls-creating-a-custom-npm-package-with-react-and-typescript/> (see pitfall 3)

solution: <https://github.com/wclr/yalc>

Development using yalc:

- npm install -g yalc
- build this project `yarn build`
- `yalc publish`
- in the project where you'd like to use this package, run `yalc add <package name>`
- this will make it so a file reference will be added to the local package in your project folder
- yalc link somehow does not work for class-transformer, so we'll have to add a precommit hook to check if we're not accidentally commiting yalc references. `yalc check`
- add to .gitignore:
- .yalc
- yalc.lock
- After changes made: `yarn build && yalc push`

Stop:

- In destination: `yalc remove --all`
- In package repo: `yalc installations clean {packageName}`
2. Apply
10 changes: 5 additions & 5 deletions docs/classes/BadRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Http error with status code 400

#### Defined in

[contracts/errors/badRequest.error.ts:9](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/badRequest.error.ts#L9)
[contracts/errors/badRequest.error.ts:9](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/badRequest.error.ts#L9)

## Properties

Expand All @@ -59,7 +59,7 @@ Http error with status code 400

#### Defined in

[contracts/errors/errorBase.error.ts:10](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L10)
[contracts/errors/errorBase.error.ts:10](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L10)

___

Expand All @@ -73,7 +73,7 @@ ___

#### Defined in

[contracts/errors/errorBase.error.ts:11](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L11)
[contracts/errors/errorBase.error.ts:11](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L11)

___

Expand All @@ -87,7 +87,7 @@ ___

#### Defined in

[contracts/errors/errorBase.error.ts:12](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L12)
[contracts/errors/errorBase.error.ts:12](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L12)

___

Expand All @@ -101,4 +101,4 @@ ___

#### Defined in

[contracts/errors/errorBase.error.ts:13](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L13)
[contracts/errors/errorBase.error.ts:13](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L13)
10 changes: 5 additions & 5 deletions docs/classes/Conflict.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Http error with status code 409 (duplicates)

#### Defined in

[contracts/errors/conflict.error.ts:9](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/conflict.error.ts#L9)
[contracts/errors/conflict.error.ts:9](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/conflict.error.ts#L9)

## Properties

Expand All @@ -57,7 +57,7 @@ Http error with status code 409 (duplicates)

#### Defined in

[contracts/errors/errorBase.error.ts:10](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L10)
[contracts/errors/errorBase.error.ts:10](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L10)

___

Expand All @@ -71,7 +71,7 @@ ___

#### Defined in

[contracts/errors/errorBase.error.ts:11](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L11)
[contracts/errors/errorBase.error.ts:11](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L11)

___

Expand All @@ -85,7 +85,7 @@ ___

#### Defined in

[contracts/errors/errorBase.error.ts:12](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L12)
[contracts/errors/errorBase.error.ts:12](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L12)

___

Expand All @@ -99,4 +99,4 @@ ___

#### Defined in

[contracts/errors/errorBase.error.ts:13](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L13)
[contracts/errors/errorBase.error.ts:13](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L13)
58 changes: 29 additions & 29 deletions docs/classes/ErrorBase.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,39 @@ Base for API Error

## Table of contents

### Constructors

- [constructor](ErrorBase.md#constructor)

### Properties

- [code](ErrorBase.md#code)
- [reason](ErrorBase.md#reason)
- [message](ErrorBase.md#message)
- [payload](ErrorBase.md#payload)

### Constructors
## Constructors

- [constructor](ErrorBase.md#constructor)
### constructor

**new ErrorBase**(`code`, `reason`, `message`, `payload?`)

#### Parameters

| Name | Type |
| :------ | :------ |
| `code` | [`StatusCode`](../enums/StatusCode.md) |
| `reason` | `string` |
| `message` | `string` |
| `payload?` | `object` |

#### Overrides

HttpError.constructor

#### Defined in

[contracts/errors/errorBase.error.ts:15](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L15)

## Properties

Expand All @@ -41,7 +64,7 @@ Base for API Error

#### Defined in

[contracts/errors/errorBase.error.ts:10](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L10)
[contracts/errors/errorBase.error.ts:10](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L10)

___

Expand All @@ -51,7 +74,7 @@ ___

#### Defined in

[contracts/errors/errorBase.error.ts:11](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L11)
[contracts/errors/errorBase.error.ts:11](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L11)

___

Expand All @@ -65,7 +88,7 @@ HttpError.message

#### Defined in

[contracts/errors/errorBase.error.ts:12](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L12)
[contracts/errors/errorBase.error.ts:12](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L12)

___

Expand All @@ -75,27 +98,4 @@ ___

#### Defined in

[contracts/errors/errorBase.error.ts:13](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L13)

## Constructors

### constructor

**new ErrorBase**(`code`, `reason`, `message`, `payload?`)

#### Parameters

| Name | Type |
| :------ | :------ |
| `code` | [`StatusCode`](../enums/StatusCode.md) |
| `reason` | `string` |
| `message` | `string` |
| `payload?` | `object` |

#### Overrides

HttpError.constructor

#### Defined in

[contracts/errors/errorBase.error.ts:15](https://github.com/Panenco/papi/blob/894fdec/src/contracts/errors/errorBase.error.ts#L15)
[contracts/errors/errorBase.error.ts:13](https://github.com/Panenco/papi/blob/db78196/src/contracts/errors/errorBase.error.ts#L13)
40 changes: 20 additions & 20 deletions docs/classes/ErrorRepresentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,47 @@ Output DTO for HTTP Errors

## Table of contents

### Constructors

- [constructor](ErrorRepresentation.md#constructor)

### Properties

- [message](ErrorRepresentation.md#message)
- [reason](ErrorRepresentation.md#reason)

### Constructors
## Constructors

- [constructor](ErrorRepresentation.md#constructor)
### constructor

## Properties
**new ErrorRepresentation**(`error?`)

### message
#### Parameters

**message**: `string`
| Name | Type |
| :------ | :------ |
| `error?` | [`ErrorBase`](ErrorBase.md) |

#### Defined in

[contracts/representations/error.representation.ts:14](https://github.com/Panenco/papi/blob/894fdec/src/contracts/representations/error.representation.ts#L14)
[contracts/representations/error.representation.ts:20](https://github.com/Panenco/papi/blob/db78196/src/contracts/representations/error.representation.ts#L20)

___
## Properties

### reason
### message

**reason**: `string`
**message**: `string`

#### Defined in

[contracts/representations/error.representation.ts:18](https://github.com/Panenco/papi/blob/894fdec/src/contracts/representations/error.representation.ts#L18)

## Constructors

### constructor
[contracts/representations/error.representation.ts:14](https://github.com/Panenco/papi/blob/db78196/src/contracts/representations/error.representation.ts#L14)

**new ErrorRepresentation**(`error?`)
___

#### Parameters
### reason

| Name | Type |
| :------ | :------ |
| `error?` | [`ErrorBase`](ErrorBase.md) |
**reason**: `string`

#### Defined in

[contracts/representations/error.representation.ts:20](https://github.com/Panenco/papi/blob/894fdec/src/contracts/representations/error.representation.ts#L20)
[contracts/representations/error.representation.ts:18](https://github.com/Panenco/papi/blob/db78196/src/contracts/representations/error.representation.ts#L18)
Loading

0 comments on commit bbe3168

Please sign in to comment.