Simple Ping Example

Creating a ping service in FaasPlus is straightforward and simple. Here’s how it works:


export async function handler(event) {
    return 'pong';
}
>response
pong                                   

Now, let’s enhance our example to include the execution time. This version returns both the "pong" response and the current date and time using the new Date() function.


export async function handler(event) {
    const executedAt = new Date().toString();
    return {
        res: 'pong',
        executed_at: executedAt
    };
}
>response
{
    "res": "pong",
    "executed_at": "Thu Sep 12 2024 12:43:23 GMT+0000 (Coordinated Universal Time)"
}