This application relies on Cloudflare's wrangler.
We use bun for development, but npm should work fine as well.
We use Auth.js for authentication, and in production we use GitHub OAuth as a provider. If you want to use something else the code for configuring providers is in src/lib/auth.ts
.
To setup environment variables, create .dev.vars
file with the following:
AUTH_SECRET=
AUTH_GITHUB_ID=
AUTH_GITHUB_SECRET=
You can create AUTH_SECRET
value with:
openssl rand -base64 33
For the two other values, follow this tutorial at Auth.js.
Create a D1 database in Cloudflare and copy its id and name into wrangler.toml
. Then run:
bun wrangler d1 execute YOUR_DB_NAME --local --file src/schema.sql
After setting up that you can start a server with:
bun run preview
To create a hot-reload server instead, use:
bun run dev
Some functionality is limited in hot-reload due to limitations of wrangler.
Make sure you're logged in with:
bun wrangler login
Set up the remote database:
bun wrangler d1 execute pluto --remote --file src/schema.sql
And then deploy:
bun wrangler deploy
There's only one incoming API at the moment:
POST /api/v1/publish
Content-Type: application/json
Authorization: Bearer {SECRET}
{
subjectId: string;
subjectKind: 'content';
platformId: string;
}
Where subjectId
is the content id, and platformId
being the id relating to your platform.
Wallo also makes a callback request either of two types:
POST {CALLBACK URL}/v1
Content-Type: application/json
Authorization: Bearer {SECRET}
{
subjectId: string;
subjectKind: 'content';
}
Of which the callback URL should respond with the content that the subjectId
is associated with. The callback URL must include the version ID. In the form of v1
.
It should respond with the following format:
type Response = {
medias: Media[];
possibleActions: PossibleAction[];
};
type PossibleAction = {
id: string;
display?: string;
variant?: 'default' | 'secondary' | 'destructive' | 'outline';
};
type Media =
| {
kind: 'text';
message: string;
tag?: string;
}
| {
kind: 'image';
url: string;
alt?: string;
tag?: string;
}
| {
kind: 'video';
url: string;
tag?: string;
};
POST {CALLBACK URL}
Content-Type: application/json
Authorization: Bearer {SECRET}
{
subjectId: string;
subjectKind: 'content';
action: string;
}