App Backend
The backend is a Node app under app-backend/. You implement business logic; the Appnest stack loads server.js, wires routing, and exposes your exports to the platform.
Entry point: app-backend/server.js
- Only functions exported from
server.jscan be invoked by the platform (backend API calls, event handlers, scheduled work—per yourmanifest.json). - Register API surfaces under
backend_api_functionsand event handlers underevent_listener_functions(eachhandlermust match an export name). Full schema: Manifest.
AppnestFunctions for backend code
| Need | Module | Doc |
|---|---|---|
| Outbound HTTP | $fetch | External API |
| Key/value storage | $db | Data Storage |
| Files (signed URLs, list, delete, …) | $file | File Storage |
| Scheduling | $schedule | Schedule |
| Call another backend function | $next | Background Job |
How to code
- Use CommonJS only:
require/module.exports. Do not useimport/export/import()inapp-backend(thevalidatecommand enforces this). - Keep export names identical to keys in
manifest.jsonso validation passes.
Rules
- Manifest alignment: Every
backend_api_functionskey and every eventhandlermust exist as a real export onserver.js. - Validation: Run
appnest-development-engine app validatebefore commits or in CI (lint + manifest checks). - Unused catch binding: If you do not use the error, use a parameterless
catch { }(notcatch (e)with an unusede).
Returning data to the frontend
When the UI invokes a backend function, the client typically receives an object shaped like { statusCode, body }: statusCode is an HTTP-style code (e.g. 200, 400, 401); body is what the function returned. If your backend uses a ResultData({ body, statusCode }) (or equivalent) helper, those values flow through to the client; otherwise the framework may default statusCode (e.g. 200) and put a plain return value in body. Exact behavior can depend on your app template—test against your scaffold.
Local dev note
Under the dev proxy, backend traffic is usually available under paths such as /app-backend/.... You do not run a separate public HTTP server for normal Appnest local development.
Further reading (this site)
| Topic | Document |
|---|---|
| App shape & project layout | App Overview |
Manifest schema & installation_parameters | Manifest |
| Appnest Functions | Appnest Functions overview |
| Engine & CLI | Development Engine overview, Commands |