Masque is a first-party headless CMS for Elixir backed by PostgreSQL. This lightweight library is designed to integrate seamlessly into your existing application.
def deps do
[
{:masque, "~> 0.1.0"}
]
end
To get started, you'll first need to add and run migrations to create Masque's database tables.
The Masque.Migrations
module provides up
and down
functions to
migrate your PostgreSQL database. Create a migration with
mix ecto.gen.migration
:
defmodule MyApp.Repo.Migrations.SetupMasque do
use Ecto.Migration
def up do
Masque.Migrations.Postgres.up()
end
def down do
Masque.Migrations.Postgres.down()
end
end
Content types in Masque are defined using JSON Schema. JSON Schema allows you to define constraints around your content so your front-end can reliably consume them without having its own set of validations. You can compose and reference other schemas, which Masque leverages to allow recursive or nested content types.
Masque provides two schemas: ContentType
and ContentItem
. A content type
describes your content’s properties and constraints using JSON Schema. Content
items are instantiations of a content type, and must match its schema.
To keep the content model simple, nested content is embedded as a copy instead of using any sort of association. Masque provides features that will help you identify and update stale embedded content, if necessary.
Content types defined by Masque can be versioned. When consuming content, the version is provided so your front-end can either exclude or handle the outdated format.
If you so choose, content types can be scoped, i.e. their JSON schema $id
will include a prefix of your choice. This is entirely optional, but allows
for different users or groups to create schemas that may have name conflicts.
For example, using the acme
prefix for a companies
schema will yield
/schemas/acme/companies/v1
as the schema ID.