Before API versions → 1 apps, folders and per-folder permissions · firmware 0.4
BreakingWhat changed
- An app is now a folder on the card with an
index.htmland anapp.jsonbeside it. The manifest names the API version the app needs and, for paths inside its folder, whethereveryoneor only theownermayread,browse,uploadanddelete. Anything not mentioned defaults to read for everyone and everything else for the owner. - The four device-wide guest switches are gone, and so is
GET/POST /auth/permissions. What a visitor may do is decided per folder by the app that lives there, as narrowed by the owner’s.app-overrides.json. - Guests can no longer write at the top level of the card unless a root
app.jsonsays so. A single.htmlfile at the top level is served read-only; the admin page offers to give it its own folder. - Four files are the owner’s to write whatever any manifest says:
app.json,.app-overrides.jsonandindex.htmlin an app folder, and/.settings.json. Deleting an app folder outright is the owner’s too. - GPIO is closed to guests until the owner allows it from the admin page (an app asks with
"gpio": truein its manifest; the grant lands in.app-overrides.json). readcan be restricted: a folder with"read": "owner"answers401to guests, for pages and data alike.- The homepage is a folder.
GET /homereturns{"folder", "exists"},POST /hometakes{"folder"}, and/redirects to/<folder>/rather than serving the file in place (the top level is still served in place). The choice lives in/.settings.jsonon the card. - A directory URL serves its
index.html;/whiteboardredirects to/whiteboard/so relative URLs resolve inside the folder. - Some top-level folder names are reserved because they are routes:
files,pin,auth,apps,admin,home,wifi,status,storage,benchmark,diagnostics,reboot,websocket,fs-info,device-name,version. - New:
GET /version,GET /apps(every app’s resolved rules, public) andPOST /files/rename(owner).
What to change in an app
- Put it in a folder as
index.htmland add anapp.json:{"api": 1, "title": "…", "paths": {"/": {"upload": "everyone"}}}, naming only the verbs it needs. The apps page’s examples are the reference. - Put
pocket.js(from the author’s guide) besideindex.htmland usePocket.readJson/Pocket.write/Pocket.list/Pocket.pininstead of rawfetchcalls; it sends the header that keeps a401out of the browser’s password box and turns it into a message. - Keep its data beside
index.htmland address it relatively:fetch('board.json'), notfetch('/board.json'). Upload withPOST /files?path=<its folder>; read the folder fromlocation.pathnamerather than hard-coding its name, so the folder can be renamed. - Stop reading
/auth/permissions. If the app wants to hide controls a guest can’t use, read its own entry inGET /apps. - On a
401, tell the person in words what needs the owner (“Deleting needs the owner’s password”); never retry silently or show a raw status code. - If it uses the pins, add
"gpio": trueto the manifest and explain a401as “the owner has to allow pin control from the app’s folder on the admin page”. - If it read
GET /homefor a file path, readfolderinstead.