Pre-built code blocks

Members area with profiles and a directory

Members area: the gate, member profiles, an opt-in member directory, groups with forum threads and an activity feed, courses with per-member progress, direct messages with block and report, and an install as a phone web app

For when the answer to “People sign in to a members area: profiles, a member directory, and private groups with a forum and feed” is yes.

A members area is the place a paying or signed-up customer goes that the public does not.

Skip the rebuild

You do not write this one. It arrives in your project as ordinary source you can read, change and keep, with its audit record and its caveats beside it.

  1. Download the Playground. It is free and runs on your own machine.
  2. Start a new app and tick “People sign in to a members area: profiles, a member directory, and private groups with a forum and feed”.
  3. This block is written in, along with anything else you ticked.

Download the Playground See the other blocks

The mistake it removes

Six, and all are quiet. A members gate with no real identity behind it denies nothing while looking complete, so the gate refuses to be built without the host app's own account lookup and stays closed when that lookup breaks. A directory that lists every member publishes a list of your customers, so being listed is opt-in and a profile is shown through an allowlist. And a group post shown to anyone outside the group is a private conversation leaked: every read and write in community.js checks membership on the server at the moment of the request, the home feed is built only from the caller's own groups, an invite-only group answers a stranger exactly as a missing one does, and the handlers take the account from the gate and ignore any accountId a caller writes into the request. Courses follow the same rule: a lesson is readable only by someone the course's gate lets in, checked at every request, a hidden course answers exactly like a missing one, an entitlement course with no entitlement check lets nobody in, and progress is keyed by the member's own account with no way to ask for anyone else's. And a direct message shown to anyone but its two participants is the most private leak of all: every read in messages.js checks that the caller is one of the two, an outsider is answered exactly as if the conversation did not exist, a member can open a conversation only with someone they share a group with, a block stops new messages both ways without announcing itself and can name only a member the blocker shares a group or a conversation with, a member reports a given message once, and the notifier the host passes never receives the words. And an installed members app can leak on a shared phone: a service worker that cached what it saw would hand the last member's feed or messages to the next person who opens it offline. node/pwa.js caches only the shell the host names, fetches it without cookies, refuses any shell answer marked private, no-store or varying by Cookie or Authorization, never touches the members API, and drops its cache on the sign-out message.

What the audit found

Named rather than summarized. The reasoning behind each one ships inside the block, so it travels with the code instead of living on a page you have to trust. A finding marked fixed was fixed after the audit ran; the verdict above is still the one the audit gave.

What you still have to do

A copied file cannot own your secrets, your host or your legal obligations. This is the part the block deliberately does not claim.

What lands in your project

node

  • node/members.js
  • node/community.js
  • node/courses.js
  • node/messages.js
  • node/pwa.js

No package is imported and no database is assumed. members.js is pure functions: requireMember(resolveAccount) builds the gate from the host app's own account lookup; publicProfile, directory and canEditProfile take plain objects. community.js takes a store with four async methods (get, set, del, list by prefix), ships memoryStore() as a reference for tests and local development, exports communityHandlers({ gate, community }) as framework-free route handlers, and limits posting to postLimit ({ max, windowMs }, default 10 in 60 seconds) per member per group. Every service also takes limits: per-member sliding windows on group creation, joins, invites and reads (community.js), course creation, adding lessons, completing lessons and reads (courses.js), and sending, reads, blocks and reports (messages.js), with the defaults exported as DEFAULT_LIMITS, DEFAULT_COURSE_LIMITS and DEFAULT_MESSAGE_LIMITS. courses.js takes the same store plus the host's optional hasEntitlement(account, entitlement) and canAuthor(account), and exports courseHandlers({ gate, courses }). messages.js takes the same store plus a REQUIRED notify({ toAccountId, fromAccountId, conversationId, messageId }), which never carries the message text, and exports messageHandlers({ gate, messaging }); reports() is for the host's moderators and has no route handler. To erase one member, the host calls eraseAccount(accountId) on community, courses and messaging alike: memberships, invites, progress, conversation pointers, blocks and rate records are deleted, and the member's posts and messages keep their place with the words blanked and the author replaced by a fresh random id. Reports and community audit records are kept with the member's id replaced the same way. setRole, removeMember, leaveGroup and deletePost each write an append-only audit record under audit:<groupId>:<auditId> before the change; the host reads a group's trail with store.list('audit:<groupId>:'). eraseAccount has no route handler; who may erase is the host's decision. Lists that can grow come back one page at a time: discoverGroups, myGroups, myConversations, myBlocks and reports() take { limit, cursor } (50 by default, never more than 200, a bad one is a 400) and answer nextCursor, and the handlers read limit and cursor from the query. A thread's replies come the same way. The group feed, a thread, the home feed and a conversation read newest-first index records (threadhead/threadpage, replyhead/replypage, dmhead/dmpage) through get and never list a group's posts or a conversation's messages, so a page reads about one record per item on it; the feeds answer nextBefore, the before for the next page. Data written before those indexes (schemaVersion 1) is indexed the first time its group or conversation is used. myCourses reads the caller's own groups and a per-gate course index, and calls hasEntitlement once per distinct entitlement, not once per course. Every read-then-write count runs under withKeyLock(key) (community.js), one at a time per key in the process, so a simultaneous burst against one server lets exactly the limit through. That lock does not reach a second server instance, so the store may offer a fifth, optional method, update(key, fn): fn(current) is synchronous, returns the next value (undefined deletes the key), and may be called more than once by a store that retries on a conflict. When the store has it, every per-member rate count goes through it, and a burst spread over several servers on one store lets exactly the limit through too (test/race.test.mjs section 5); memoryStore() has one. Lesson numbering and the lesson completion record span more than one key and stay on the in-process lock. pwa.js exports membersManifest, membersServiceWorker, pwaHandlers and membersRegisterSnippet: the host mounts the manifest at <scope>manifest.webmanifest and the worker at <scope>sw.js, outside the members gate since neither holds member data, and posts the sign-out message from its sign-out page. The scaffold copies these five files into a new app's server/blocks/ and mounts none of their handlers, the same as every other block: the host mounts communityHandlers, courseHandlers, messageHandlers and pwaHandlers on its own router, behind its own gate and store.

What you supply

Licensed MIT. It is a starting point, not a finished product.

Get it

Download the Playground See the other blocks

Nothing here is locked. The files are yours, in your folder, under a permissive license.

Questions

Is Members area with profiles and a directory audited?
It was audited on 2026-09-29, and the verdict was not a clean pass. 8 findings have been fixed since then, and the verdict stands until the block is audited again.
What do I still have to do myself?
A request limiter in front of every handler, per IP or per session. This block limits each member: posting per group (test/community.test.mjs section 10), and creating groups, joining, inviting and reading (section 11), creating courses and reading courses (test/courses.test.mjs section 8), sending and reading direct messages (test/messages.test.mjs section 11), and blocking and reporting (section 12). Adding and completing lessons are limited too (test/courses.test.mjs section 11). Those counts are per account, so one person with many accounts gets many allowances. Each count is taken under a per-key lock, so a burst against one server process gets exactly the limit (test/race.test.mjs, raced on three stores); a host running several server instances on one store is covered only when its store offers the optional atomic update(key, fn), which every per-member count then uses (test/race.test.mjs section 5, two servers over one store). Blocking and reporting are bounded by key as well as by rate: a member reports a given message once (a repeat returns the first report), blocks only someone they share a group or a conversation with, and keeps at most 500 accounts on their block list (MAX_BLOCKS_PER_ACCOUNT in node/messages.js).
How do I get this code?
Download the Playground, start a new app, and tick “People sign in to a members area: profiles, a member directory, and private groups with a forum and feed”. The block is written into your project as ordinary source you can read and edit.

All pre-built code blocks · Learn to build from zero · The coding guide