Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/christopherlai/storyblok
https://github.com/christopherlai/storyblok
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/christopherlai/storyblok
- Owner: christopherlai
- Created: 2023-05-06T03:41:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-14T04:40:04.000Z (9 months ago)
- Last Synced: 2024-10-18T16:49:58.523Z (2 months ago)
- Language: Elixir
- Size: 38.1 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Storyblok
## Installation
The [package](https://hex.pm/packages/storyblok) can be installed by adding `storyblok` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:storyblok, "~> 2023.12.24-beta.1"}
]
end
```## Configuration
### Storyblok API Token
The Storyblok `token` can be configured 2 ways.
#### Application
To configure the `token` for your entire application, add the following to your config file.
```elixir
import Configconfig :storyblok, token: ""
```#### Per Request
Alternatively, the `token` can be configured per request by passing `token` to `Storyblok.request`.
```elixir
"123"
|> Storyblok.Story.get()
|> Storyblok.request(token: "")
```## Caching
The default configuration is to disable caching, every request hits the Storyblok API.
Caching can be enabled by setting the follow configs.
```elixir
import Configconfig :storyblok, cache: true, cache_store: MyApp.CacheModule
```Any store can be used for caching (Redis, MemCached, etc), your application must implement the `Storyblok.Cache` behaviour.
```elixir
defmodule MyApp.CacheModule do
def fetch(key, opts) do
case MyApp.get(key, opts) do
{:ok, data} -> {:ok, data}
{:error, _reason} -> {:error, :not_found}
end
enddef set(key, value, expire_in_ms, opts) do
case MyApp.set(key, value, expire_in_ms, opts) do
{:ok, _data} -> :ok
{:error, reason} -> {:error, reason}
end
end
end
```