Skip to content

Commit

Permalink
chore: stay backward-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
hxjo committed Jul 17, 2024
1 parent ea990af commit 782e88a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 24 deletions.
Binary file modified .coverage
Binary file not shown.
28 changes: 22 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.6] - 2024-07-17

- Cache vite manifest content
- Better type vite manifest
- Allow for multiple css files to be in the manifest file
- Deprecate use_typescript in favour of entrypoint_filename
- Will be removed in 1.0.0
- Introduce root_directory to InertiaConfig instead of assuming it
- Introduce assets_prefix to InertiaConfig instead of assuming it

## [0.1.5] - 2024-07-17

- Introduce new dev dependency: BeautifulSoup
- Use it instead of manual parsing as this is more reliable and less painful

## [0.1.4] - 2024-05-31

* Handle better JSONification of Pydantic models
* Use `json.loads(model.model_dump.json())` rather than `model.model_dump()`
- Handle better JSONification of Pydantic models
- Use `json.loads(model.model_dump.json())` rather than `model.model_dump()`
To avoid issues with some common field types (UUID, datetime, etc.)
* Expose a `_render_json` method on inertia to allow easier overriding.
- Expose a `_render_json` method on inertia to allow easier overriding.

## [0.1.3] - 2024-05-08

* Bump FastAPI version from 0.110.2 to 0.111.0
- Bump FastAPI version from 0.110.2 to 0.111.0

## [0.1.2] - 2024-04-23

* Update `README.md` and available versions
- Update `README.md` and available versions

## [0.1.1] - 2024-04-23

* Initial release.
- Initial release.
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,23 @@ pip install fastapi-inertia
You can configure the adapter by passing a `InertiaConfig` object to the `Inertia` class.
The following options are available:

| key | default | options | description |
| ------------------- | -------------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| environment | development | development,production | The environment to use |
| version | 1.0.0 | Any valid string | The version of your server |
| json_encoder | InertiaJsonEncoder | Any class that extends json.JSONEncoder | The JSON encoder used to encode page data when HTML is returned |
| manifest_json_path | ./dist/.vite/manifest.json | Any valid path | The path to the manifest.json file. Needed in production |
| dev_url | http://localhost:5173 | Any valid url | The URL to the development server |
| ssr_url | http://localhost:13714 | Any valid url | The URL to the SSR server |
| ssr_enabled | False | True,False | Whether to [enable SSR](#enable-ssr). You need to install the `requests` package, to have set the manifest_json_path and started the SSR server |
| root_directory | src | Any valid path | The directory in which is located the javascript code in your frontend. Will be used to find the relevant files in your manifest.json. |
| entrypoint_filename | main.js | Any valid file | The entrypoint for you frontend. Will be used to find the relevant files in your manifest.json. |
| use_typescript | False | True,False | Whether to use TypeScript |
| use_flash_messages | False | True,False | Whether to use [flash messages](#flash-messages). You need to use Starlette's SessionMiddleware to use this feature |
| flash_message_key | messages | Any valid string | The key to use for [flash errors](#flash-errors) |
| use_flash_errors | False | True,False | Whether to use flash errors |
| flash_error_key | errors | Any valid string | The key to use for flash errors |
| key | default | options | description |
| ------------------- | ---------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| environment | development | development,production | The environment to use |
| version | 1.0.0 | Any valid string | The version of your server |
| json_encoder | InertiaJsonEncoder | Any class that extends json.JSONEncoder | The JSON encoder used to encode page data when HTML is returned |
| manifest_json_path | "" | Any valid path | The path to the manifest.json file. Needed in production |
| dev_url | http://localhost:5173 | Any valid url | The URL to the development server |
| ssr_url | http://localhost:13714 | Any valid url | The URL to the SSR server |
| ssr_enabled | False | True,False | Whether to [enable SSR](#enable-ssr). You need to install the `requests` package, to have set the manifest_json_path and started the SSR server |
| root_directory | src | Any valid path | The directory in which is located the javascript code in your frontend. Will be used to find the relevant files in your manifest.json. |
| entrypoint_filename | main.js | Any valid file | The entrypoint for you frontend. Will be used to find the relevant files in your manifest.json. |
| assets_prefix | "" | Any valid string | An optional prefix for your assets. Will prefix the links generated from the assets mentioned in manifest.json. |
| use_typescript | False | True,False | Whether to use TypeScript |
| use_flash_messages | False | True,False | Whether to use [flash messages](#flash-messages). You need to use Starlette's SessionMiddleware to use this feature |
| flash_message_key | messages | Any valid string | The key to use for [flash errors](#flash-errors) |
| use_flash_errors | False | True,False | Whether to use flash errors |
| flash_error_key | errors | Any valid string | The key to use for flash errors |

## Examples

Expand Down
15 changes: 13 additions & 2 deletions inertia/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import lru_cache
import json
from typing import Literal, Type, Optional, TypedDict, Dict, cast
from typing import Literal, Type, Optional, TypedDict, Dict, Union, cast
import warnings
from json import JSONEncoder
from .utils import InertiaJsonEncoder
from dataclasses import dataclass
Expand All @@ -18,14 +19,24 @@ class InertiaConfig:
dev_url: str = "http://localhost:5173"
ssr_url: str = "http://localhost:13714"
ssr_enabled: bool = False
manifest_json_path: str = "./dist/.vite/manifest.json"
manifest_json_path: str = ""
root_directory: str = "src"
entrypoint_filename: str = "main.js"
use_flash_messages: bool = False
use_flash_errors: bool = False
flash_message_key: str = "messages"
flash_error_key: str = "errors"
assets_prefix: str = ""
use_typescript: Union[bool, None] = None

def __post_init__(self) -> None:
if self.use_typescript is not None:
warnings.warn(
"use_typescript is deprecated: Please use entrypoint_filename instead. It will be removed in 1.0.0",
DeprecationWarning,
stacklevel=2,
)
self.entrypoint_filename = "main.ts" if self.use_typescript else "main.js"


class ViteManifestChunk(TypedDict):
Expand Down

0 comments on commit 782e88a

Please sign in to comment.