Scale up as you grow β whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Hello community π
Iβm new to the DO and right now interested particularly in scheduled functions to automate my processes.
Using this documentation https://docs.digitalocean.com/products/functions/how-to/create-functions/ I created serverless function within typescript template.
My main issue While I was working within 1 file function by testing different triggers and deployments - everything was fine. When I add additional folders and helper functions - it stops running.
Function logs
{
"namespace": "fn-a0450dcf-a2f0-4ce8-ae58-63b3e2fd2f6c",
"name": "autopet",
"version": "0.0.36",
"publish": false,
"annotations": [
{
"key": "path",
"value": "fn-a0450dcf-a2f0-4ce8-ae58-63b3e2fd2f6c/fireball/autopet"
},
{
"key": "waitTime",
"value": 47
},
{
"key": "uuid",
"value": "b0ec5d8b-de9f-44eb-b666-542f51b3b179"
},
{
"key": "entry",
"value": "lib/autopet.js"
},
{
"key": "user_id",
"value": "16702566"
},
{
"key": "gbs",
"value": 0
},
{
"key": "kind",
"value": "nodejs:14"
},
{
"key": "timeout",
"value": false
},
{
"key": "limits",
"value": {
"logs": 16,
"memory": 256,
"timeout": 3000
}
},
{
"key": "initTime",
"value": 2409
}
],
"subject": "b0ec5d8b-de9f-44eb-b666-542f51b3b179",
"activationId": "b5d27fa6e0854d89927fa6e085ed89e4",
"end": "1717980782028",
"start": "1717980782028",
"duration": 0,
"response": {
"result": {
"error": "The function did not initialize properly."
},
"size": 53,
"status": "developer error",
"success": false
},
"logs": [
"2024-06-10T00:53:04.391904024Z stdout: Function entrypoint 'lib/autopet.js' is not a function."
],
"statusCode": null
}
Structure
packages/fireball/autopet/
βββ src/
β βββ autopet.ts
β βββ shared/
β βββ constants.ts
β βββ index.ts
βββ lib/
β βββ autopet.js
β βββ shared/
β βββ constants.js
β βββ index.js
βββ package.json
βββ tsconfig.json
project.yml
packages:
- name: fireball
functions:
- name: autopet
binary: false
main: 'lib/autopet.js'
runtime: nodejs:default
web: true
webSecure: false
tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"esModuleInterop": true,
"module": "commonjs",
"outDir": "lib",
"rootDir": "src",
"target": "es2019",
"types": ["node"],
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}
package.json
{
"main": "lib/autopet.js",
"devDependencies": {
"@types/node": "^20.14.2",
"dotenv": "^16.4.5",
"prettier": "^3.3.1",
"typescript": "5.1"
},
"scripts": {
"build": "tsc -b"
},
"dependencies": {
"axios": "^1.7.2",
"discord.js": "^14.15.3",
"ethers": "^6.13.0"
},
"engines": {
"node": ">=16.0.0"
}
}
autopet.ts
import { POLYGON_RPC } from './shared';
export function main(_args_: {}): {} {
let name: _string_ = _args_['name'] || 'stranger';
let greeting: _string_ = `Hello ${name}, here's rpc url: ${POLYGON_RPC}`;
console.log(greeting);
return { body: greeting };
}
lib/autopet.js
"use strict";
_Object_.defineProperty(_exports_, "__esModule", { value: true });
_exports_.main = void 0;
const shared_1 = require("./shared");
function main(_args_) {
let name = _args_['name'] || 'stranger';
let greeting = `Hello ${name}, here's rpc url: ${shared_1.POLYGON_RPC}`;
console.log(greeting);
return { body: greeting };
}
_exports_.main = main;
Rory McEwan
Anjanesh Lekshminarayanan
182d09356ab94d3893ddfaca4f0270
Prashant Kumbhat
kprichard
e452769e8f30404d81a3bc803143f4
robert
Eleanor
GamesmenJordan