Integrated Haskell Platform
Learn how to configure IHP for use with Filebase.
Integrated Haskell Platform, or IHP, is a full-stack framework developed to focus on rapid application deployment that utilizes robust code. IHP features a fully managed development environment, integrated development tooling, and quick response times within your production environment.
IHP has native integration for Filebase, making uploading to Filebase within your IHP code a single, seamless function. That means there’s no configuration of Filebase settings or endpoints needed, just your Filebase Access and Secret key pair.
Read below to learn how to use IHP with Filebase.
Insert the following line to import the
IHP.FileStorage.Config
package:import IHP.FileStorage.Config
module Config where
import IHP.Prelude
import IHP.Environment
import IHP.FrameworkConfig
import IHP.FileStorage.Config
config :: ConfigBuilder
config = do
option Development
option (AppHostname "localhost")
initFilebaseStorage "FILEBASE_BUCKET_NAME"
Replace FILEBASE_BUCKET_NAME with your Filebase bucket name.
You can do so with the commands:
export FILEBASE_KEY="FILEBASE ACCESS KEY"
export FILEBASE_SECRET="FILEBASE SECRET KEY"
You can also set these as static variables in your IHP
./start
script:#!/usr/bin/env bash
# Script to start the local dev server
# ...
export FILEBASE_KEY="FILEBASE ACCESS KEY"
export FILEBASE_SECRET="FILEBASE SECRET KEY"
# Finally start the dev server
RunDevServeras
action UpdateCompanyAction { companyId } = do
company <- fetch companyId
company
|> fill @'["name"]
|> uploadToStorage #logoUrl
>>= ifValid \case
Left company -> render EditView { .. }
Right company -> do
company <- company |> updateRecord
redirectTo EditCompanyAction { .. }
This assumes that data is in the following schema:
CREATE TABLE companies (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
name TEXT NOT NULL,
logo_url TEXT DEFAULT NULL
);
If you have any questions, please join our Discord server, or send us an email at [email protected]
Last modified 1yr ago