A sample function: tryAsync

index.mjs
// Async function
export const tryAsync = (ctx, data) => {
  console.log('Data received: %o', data);
  ctx.send(data);
};

// HTTP sync function
export const tryKnative = (req, res) => {
  res.send(`Hello, ${req.query.u || 'World'}!`);
};

package.json
{
  "main": "index.mjs",
  "scripts": {
    "start": "functions-framework --target=tryKnative"
  },
  "dependencies": {
    "@openfunction/functions-framework": "^0.4.1"
  }
}
Notice
  • Serveral async and sync functions CAN be placed in ONE SINGLE JavaScript file
    • Target function CAN be assigned when applying Function CR manifest
  • In package.json, sciprts and dependencies sections could be omitted