Skip to content

Instantly share code, notes, and snippets.

Building APIs for a headless frontend: namespaced controllers, not global filters

This is how we want to build REST APIs for our headless frontends going forward. It came out of comparing two real approaches in our own codebases, so the examples are concrete.

The two approaches

Approach A, the cfr-api way: global rest_prepare_{post_type} filters.

{
"success" : true,
"request" : {
"username" : "saoc1DW3HP",
"publicKeyCredentialCreationOptions" : {
"challenge" : "5aVlUQilvoJ4XA20UXizyO5PK0W5cHRBcKPStpxoKec",
"excludeCredentials" : [
{
"type" : "public-key",
"id" : "jF5ABPtLTvhPLqI4sJbCQsl-goA",
@Zmetser
Zmetser / auth.js
Last active September 24, 2024 18:12
const registerURL = "https://level2.d13s.com/m/webauthn/register";
const authURL = "https://level2.d13s.com/m/webauthn/authenticate";
const appToken = "D-lnChRTnKj9eMhmqiIhHEFoo/ER3G8d1Ke4oezHpq1MA";
async function register() {
const response = (await getRegisterChallenge()).request;
console.log("register response", response);
const credential = await createCredential(response);
== REGISTRATION ==
"[PASSKEY] register data" {
"success" : true,
"request" : {
"username" : "iCd91b3BM0",
"publicKeyCredentialCreationOptions" : {
"challenge" : "GyPeRmve2-GuHc5AuzduXg9SC4lvzM24fAFiWunCcwk",
"excludeCredentials" : [
diff --git a/Maze/Shared/Views/Editor/EditorView.swift b/Maze/Shared/Views/Editor/EditorView.swift
index 6f7ef845..c49d0822 100644
--- a/Maze/Shared/Views/Editor/EditorView.swift
+++ b/Maze/Shared/Views/Editor/EditorView.swift
@@ -55,11 +55,11 @@ struct EditorView: View {
.onDisappear {
// Only run when the view is visible to the user.
// Disables running when navigating away from the screen. This prevents self.focusEditor to throw a runtime error
- if isPresented {
- if !disableBlurHandler && isFocused {
felújítás így sem volt zökkenőmentes a szakértő szerint, hiszen ennek a típusnak a karosszériája egészen más technológiával készült, mint a mostani autóbuszoké, ráadásul az Ikarus 30 formai megoldásai szintén merőben eltérnek az utóbbi évtizedekben megszokottól.
Fotó: Volánbusz
Fotó: Volánbusz
Fotó: Volánbusz
A restaurátorok csillagcsavart sem használhattak, hiszen ilyen sem volt az eredeti példányokon,
{length = 671722, bytes = 0x62706c69 73743030 d2010203 0e5f100f ... 00000000 000a3f26 }
{length = 38, bytes = 0x694f5320 72696368 20636f6e 74656e74 ... 61726420 74797065 }
<head><meta charset="UTF-8"></head><p style="box-sizing: border-box; transition: var(--theme); margin: 0px; padding: 0px 0px 20px; vertical-align: baseline; display: block; line-height: 1.5; word-break: break-word; max-width: calc(-30px + 100vw); caret-color: rgb(241, 241, 241); color: rgb(241, 241, 241); font-family: Inter, Helvetica, Arial, sans-serif; font-size: 17.1px; font-style: normal; font-variant-caps: normal; font-weight: 400; l
@Zmetser
Zmetser / appThreadPage.graphql
Created February 28, 2024 08:12
AppThreadPage thread query error
query AppThreadPage {
appThreadPage(uuid: "5a266409-d835-4e27-956a-569e63f553b6") {
users { name }
related_to_block { uuid }
threads {
single_block_exchange { uuid }
thread { uuid }
@Zmetser
Zmetser / TheScreen.graphql
Created February 16, 2024 16:09
Example query we're planning to do for the new Everything Page
query TheScreen {
theScreen(nodeId: String) { # this is the junction block id or the root thread id
# this is the junction block
# NULL if the thread is a root thread
related_to_block {
uuid
created_by {}
content
}
let sum = 0
for (let i = 0; i < input.length; i++) {
const [_, s1, e1, s2, e2] = /(\d{1,2})-(\d{1,2}),(\d{1,2})-(\d{1,2})/g.exec(input[i])
const series1 = Array(Number(e1) - Number(s1) + 1).fill(0).map((_, i) => i + Number(s1))
const series2 = Array(Number(e2) - Number(s2) + 1).fill(0).map((_, i) => i + Number(s2))
if (series1.length > series2.length) {
sum += series2.every(n => series1.includes(n)) ? 1 : 0 // some for 2nd part
} else {
sum += series1.every(n => series2.includes(n)) ? 1 : 0 // some for 2nd part
@Zmetser
Zmetser / input.scss
Created April 30, 2022 08:36
Generated by SassMeister.com.
@use "sass:map"; // include { map } from 'sass/map';
@use "sass:list"; // include { list } from 'sass/list';
// Lists
// 16px 24px 32px 64px
$icons: 16, 24, 32, 64, 128, 512; // JS tomb [16px, 24px]
// array.foreach(size => ...)
@each $size in $icons {
.icon-#{$size} {