Platform APIs
Fission Platform APIs
The webnative platform API provides methods to work with the apps associated with users.
The platform API makes it possible to manage user apps and, combined with the webnative filesystem methods, create and manage apps entirely from the browser.
Yes, you can build an app, that creates apps on behalf of the user! This is a way for developers to make use of the Fission Platform to build their own MicroSaaS business, including custom domains and other features for their users.
The API methods are prefixed with apps.
    apps.index: A list of all of your apps and their associated domain names
    apps.create: Creates a new app, assigns an initial subdomain, and sets an asset placeholder
    apps.publish: Publish a new app version
    apps.deleteByDomain: Destroy an app identified by domain

Permissions

Apps that use the platform API must request permission to work with a user's apps. Permissions are requested when a user signs in through the Fission Auth Lobby. See the Auth guide for more on the webnative authentication flow.
Platform API permissions are requested at permissions.platform.apps in the initialization object.
1
import * as wn from 'webnative'
2
​
3
const permissions = {
4
platform: {
5
apps: "*",
6
},
7
// ... other permissions
8
}
9
​
10
// Initialise webnative with expected permissions
11
wn.initialise({ permissions }).then(state => {
12
if (!state.authenticated) {
13
// We don't have the permissions yet.
14
// Let's send the user to auth.fission.codes and ask for them:
15
wn.redirectToLobby(permissions)
16
} else {
17
// we're all set up! πŸŽ‰
18
}
19
})
Copied!
The value at permissions.platform.apps can be
    "*": Grant complete app management access for all of the user's apps
    An array of domain names, e.g. [ "an-app.fission.app", "another-app.fission.app" ]: Grant permission to manage specific apps. Those apps can be published or deleted.

API

apps.index
Lists all user apps and their associated domain names.
Required permissions: { platform: { apps: "*" } } full app management permissions
Params: No parameters
Returns: App[] with the domain names, creation and modification times for each app
Example:
1
const index = await wn.apps.index()
2
// [
3
// { domains: ['your-fission-deployment.fission.app'],
4
// insertedAt: '<creation-time>',
5
// modifiedAt: '<last-modified-time>',
6
// }
7
// ]
Copied!
apps.create
Creates a new app, assigns an initial subdomain, and publishes a placeholder site.
Required permissions: { platform: { apps: "*" } } full app management permissions
Params:
    subdomain: string optional
Returns: { domain: string } the subdomain of the newly created app
Example:
1
const newApp = await wn.apps.create()
2
// { domain: 'your-fission-deployment.fission.app' }
Copied!
apps.publish
Publishes a new app version by IPFS CID. If the app does not exist yet, create the app first with apps.create.
Required permissions: Needs either permission for the app domain or full app management permissions. See Permissions.
Params:
    domain: string required
    cid: string required
Returns: Nothing returned
Example:
1
await sdk.apps.publish('your-fission-deployment.fission.app', 'QmRVvvMeMEPi1zerpXYH9df3ATdzuB63R1wf3Mz5NS5HQN')
Copied!
Retrieving the CID depends on where you have staged the app code. One convenient way to do this is to publish the app's HTML, CSS, JavaScript, and assets to a public directory in WNFS and retrieve the CID of that directory.
1
// The POSIX path where you published your app code in the public filesystem:
2
const appPath = `Apps/your-fission-deployment/Published`
3
​
4
const ipfs = await wn.ipfs.get()
5
const rootCid = await fs.root.put()
6
const stats = await ipfs.files.stat(`/ipfs/${rootCid}/p/${appPath}/`)
7
​
8
// The CID you use to publish with the plaform API:
9
const cid = stats.cid.toBaseEncodedString()
10
​
11
await wn.apps.publish('your-fission-deployment.fission.app', cid)
Copied!
apps.deleteByDomain
Delete an app by domain.
Required permissions: Needs either permission for the app domain or full app management permissions. See Permissions.
Params:
    url: string required
Returns: Nothing returned
Example:
1
await wn.apps.deleteByDomain('your-fission-deployment.fission.app')
Copied!
Last modified 1mo ago
Export as PDF
Copy link