A service is a piece of server-side JavaScript that your pages, apps and other services call over HTTPS. Use one for logic that must not run in the browser: secrets, validation, multi-step data changes or calls to third-party APIs.
A service is a single, dependency-free JavaScript module with one default-exported handler. Your AI assistant writes it and publishes it through the MCP server; OINO.cloud checks it, deploys it to your own service app and gives it a URL. Services never see your database credentials — everything they do goes through the platform.
export default async function handler(req, ctx) {
// req: { method, path, query, headers, body }
const res = await ctx.data.fetch("/api/v1/<customerId>/<token>")
return { status: 200, body: { ok: true } }
}
A string body is sent as-is, anything else is returned as JSON. req.path is the part after /<serviceId>/.
Everything outside the handler's own logic goes through ctx:
fetch is not available.console.log/info/warn/error is captured there too.subject, roles, appId), or null for a public service.The source is checked before anything is stored, and rejected with line and column errors if it breaks the contract:
node:crypto, node:buffer, node:url, node:util and node:querystring.import(), eval, Function, require, process, globalThis/window, raw fetch/XMLHttpRequest/WebSocket or WebAssembly.
order-submit). The id becomes part of its URL; publishing the same id again updates it in place.https://<host>/<serviceId>/..., using the URL the list reports.You can keep the source but take a service offline by publishing it as inactive. When the last service is removed, the service app is stopped.
Publishing a service does not change your database. To let it read or write data, add one of its implicit roles to the token it should use:
urn:oinocloud:svc:<customerId> — any service of yours.urn:oinocloud:svc:<customerId>:<serviceId> — one specific service.Follow the least-privilege advice from the Security guide: prefer the single-service form and a read-only token unless the service must write.
In a page, load the platform helper as a plain script and call the service like fetch():
<script src="/svc-client.js"></script>
<script type="module">
const res = await OINOServiceFetch("order-submit", "create", {
method: "POST",
body: JSON.stringify({ item: 42 })
})
</script>
OINOServiceFetch gets a short-lived token with the user's app login, caches it, re-requests it once if it expires, and also works for public services. Use await only inside an async function or a module script, and never hard-code the service host.
List every service a page calls when publishing the page. The service's roles then join the page's login roles, so everyone who can log in to the app is also allowed to call its services — otherwise a user may log in and still be refused by the service.
Tip: keep each service small and single-purpose, and let pages do the presenting. That gives you narrow roles and tokens, and makes the AI's context easy to follow.
A MCP server exposes one database through tokens, roles control access, pages present the data, apps put pages behind one login — and services add the server-side logic in between.