···25252626The Atmosphere works the same way, except we're going to check `at://` instead of `https://`. Each user has a data repo under an `at://` URL. We'll crawl all the `at://`s in the Atmosphere for all the "status.json" records and aggregate them into our SQLite database.
27272828-> `at://` is the URL scheme of the AT Protocol.
2828+> `at://` is the URL scheme of the AT Protocol. Under the hood it uses common tech like HTTP and DNS, but it adds all of the features we'll be using in this tutorial.
29293030## Step 1. Starting with our ExpressJS app
3131···278278 // If the user is signed in, get an agent which communicates with their server
279279 const agent = await getSessionAgent(req, res, ctx)
280280 if (!agent) {
281281- return res.status(401).json({ error: 'Session required' })
281281+ return res.status(401).type('html').send('<h1>Error: Session required</h1>')
282282 }
283283284284 // Construct their status record
···298298 })
299299 } catch (err) {
300300 logger.warn({ err }, 'failed to write record')
301301- return res.status(500).json({ error: 'Failed to write record' })
301301+ return res.status(500).type('html').send('<h1>Error: Failed to write record</h1>')
302302 }
303303304304 res.status(200).json({})
···310310311311```html
312312<!-- src/pages/home.ts -->
313313-<div class="status-options">
314314- ${['👍', '🦋', '🥳', /*...*/].map(status => html`
315315- <div class="status-option" data-value="${status}">
313313+<form action="/status" method="post" class="status-options">
314314+ ${STATUS_OPTIONS.map(status => html`
315315+ <button class="status-option" name="status" value="${status}">
316316 ${status}
317317- </div>`
318318- )}
319319-</div>
320320-```
321321-322322-And write some client-side javascript to submit the status on click:
323323-324324-```javascript
325325-/* src/pages/public/home.js */
326326-Array.from(document.querySelectorAll('.status-option'), (el) => {
327327- el.addEventListener('click', async (ev) => {
328328- const res = await fetch('/status', {
329329- method: 'POST',
330330- headers: { 'content-type': 'application/json' },
331331- body: JSON.stringify({ status: el.dataset.value }),
332332- })
333333- const body = await res.json()
334334- if (!body?.error) {
335335- location.reload()
336336- }
337337- })
338338-})
317317+ </button>
318318+ `)}
319319+</form>
339320```
340321341322And here we are!