Docs Menu
Docs Home
/ /
Atlas App Services
/ /

Function Configuration Files

On this page

  • Function Manifest
  • Function Source Code
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
object
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;
};

Back

Environment Values