Docs Menu
Docs Home
/ /
Atlas App Services

Function Configuration Files

On this page

  • Function Manifest
  • Function Source Code

Note

This page describes a legacy configuration file format. You should only use this information if you're using the deprecated realm-cli.

Any configuration files you pull with App Services CLI or export from the UI use the latest configuration version. For detailed information on the current configuration file format, see App Configuration.

app/
└── functions/
├── config.json
└── <function>.js

Every function in your app has a corresponding metadata entry in the function manifest file: /functions/config.json.

Tip

Atlas App Services automatically adds functions to the manifest on import if they don't already have a configuration defined. If you're okay with the default settings, you can skip defining the configuration for a function and let App Services do it for you. The manifest will include the generated configurations the next time you export or pull your app.

functions/config.json
[
{
"name": "<Function Name>",
"private": <Boolean>,
"can_evaluate": { <JSON Expression> },
"disable_arg_logs": <Boolean>,
"run_as_system": <Boolean>,
"run_as_user_id": "<App Services User ID>",
"run_as_user_id_script_source": "<Function Source Code>"
},
...
]
Field
Description
name
String
The name of the function. The name must match the file name of a source code file and be unique among all functions in your application.
private
Boolean
If true, this function may only be called from other functions or in %function rule expressions. You cannot call a private function directly from a client application or with an SDK.
can_evaluate
JSON Expression (default: true)
A JSON expression that evaluates to true if the function is allowed to execute. App Services evaluates this expression for every incoming request.
disable_arg_logs
Boolean
If true, App Services omits the arguments provided to the function from the function execution log entry.
run_as_system
Boolean
If true, this function runs as the system user. This overrides any values defined for run_as_user_id and run_as_user_id_script_source.
run_as_user_id
String
The unique ID of a App Services User that the function always executes as. Cannot be used with run_as_user_id_script_source.
run_as_user_id_script_source
String
A stringified function that runs whenever the function is called and returns the unique ID of a App Services User that the function executes as. Cannot be used with run_as_user_id.

You define a function's source code in a .js file within the /functions directory that uses the function name as its file name. Each file must export the main function that runs whenever a request calls the function.

Important

All of your function source code files must be in the /functions directory.

/functions/<function name>.js
exports = function addOne(input) {
if(typeof input !== "number") {
throw new Error("You must call addOne() with a number");
}
return input + 1;
};

Next

What are the Atlas Application Services?