Appifio Creator · Lesson EM09 · Easy Storage

Build a small blog
example · checklist · don’t mix with Aura

One loop: create a post → route → detail page. Then a pre-delivery checklist.

Prerequisites: EM01-EM06 · page file blog/detail.html already exists (EM05)

Important - Prompt & Skills

Turn on: Appifio Easy Storage - Complete AI Guide (Prompt & Skills → Appifio prompt template). The agent already has the skills - you don’t need to paste docs.

Do not also enable Appifio Aura Storage (Advanced) - Complete AI Guide at the same time.

1. Create a post (read → edit → write → route)

async function createBlog(title, author, content, tags = [], category = 'Uncategorized') {
  await window.waitForAppStorage?.();

  let blogIndex = { blogs: {}, metadata: { total: 0, last_updated: '' } };
  const result = await appifio_client.appifio_readFile('blog.json');
  if (result?.success && result.data?.exists && result.data.content) {
    try { blogIndex = JSON.parse(result.data.content); } catch (e) {}
  }

  const blogId = Date.now().toString();
  const slug = appifio_client.appifio_generateSlug(title);
  const now = new Date().toISOString().slice(0, 19).replace('T', ' ');

  blogIndex.blogs[blogId] = {
    id: blogId, title, slug, author, content,
    tags, category, created_at: now, updated_at: now
  };
  blogIndex.metadata.total = Object.keys(blogIndex.blogs).length;
  blogIndex.metadata.last_updated = now;

  const save = await appifio_client.appifio_writeFile(
    'blog.json',
    JSON.stringify(blogIndex, null, 2)
  );
  if (!save.success) throw new Error(save.message);

  // REQUIRED - without a route the post URL = 404
  await appifio_client.appifio_addRoute(slug, 'blog/detail.html', 'blog');

  return { success: true, blog: blogIndex.blogs[blogId] };
}

2. Detail page (blog/detail.html)

document.addEventListener('DOMContentLoaded', async () => {
  await window.waitForAppStorage?.();
  const slug = appifio_client.appifio_getRouteSlug();

  const r = await appifio_client.appifio_readFile('blog.json');
  if (!r.success || !r.data.exists) {
    document.body.innerHTML = '

No posts yet.

';
    return;
  }
  const data = JSON.parse(r.data.content);
  const post = Object.values(data.blogs || {}).find(b => b.slug === slug);
  if (!post) {
    document.body.innerHTML = '

Post not found.

';
    return;
  }

  document.getElementById('title').textContent = post.title;
  document.getElementById('date').textContent =
    appifio_client.appifio_formatDateTime(post.created_at, 'date');
  document.getElementById('content').innerHTML = post.content;
});

3. Delete a post - remember to remove the route

async function deleteBlogBySlug(slug) {
  await window.waitForAppStorage?.();
  const r = await appifio_client.appifio_readFile('blog.json');
  if (!r.success || !r.data.exists) return;
  const data = JSON.parse(r.data.content);
  const id = Object.keys(data.blogs).find(k => data.blogs[k].slug === slug);
  if (!id) return;
  delete data.blogs[id];
  data.metadata.total = Object.keys(data.blogs).length;
  await appifio_client.appifio_writeFile('blog.json', JSON.stringify(data, null, 2));
  await appifio_client.appifio_removeRoute(slug);
}

4. Pre-delivery checklist

Detailed method cards (AM-style) live in: EM03 (15) · EM04 (5) · EM05 (7) · EM06 (3) · EM07 (helpers) · EM08 (1)

  1. Backend = Easy + already clicked Save changes
  2. Every JSON readFile uses JSON.parse + try/catch; default structure when the file is missing (EM02)
  3. readField: check success - don’t assume Aura’s value: null (EM03)
  4. One data type = one JSON file
  5. Every URL beyond home: HTML file + addRoute (EM05-EM06)
  6. Delete content → removeRoute
  7. Navigation links use absolute URLs (EM06)
  8. Secrets only via Secrets manager / server functions (EM08)
  9. Don’t copy appendData / readList / skip-parse from Aura; don’t build AM06-style admin login

5. Easy vs Aura - quick recall

TopicEasyAura
ListsEdit the array yourself + writeFileappendData / readList / updateData
readFileString → parseAlready an object
Built-in adminNoneLogin / session
Full CMSUsually not enoughNeeds Advanced

Details: BR02 · choosing the tab: F01.

One-liner: Easy = one JSON notebook, parse by hand, overwrite the whole file, routes required, no built-in admin. Learn EM01→EM09 in order, then ask AI to build - remind the AI of checklist §4.

Easy series complete

Back to EM01 for the map · or F01 / BR02 if you’re choosing Easy vs Advanced

Appifio Creator · User guide · EM09