Skip to content

Improve typing for typescript-with-node serverless function example #42

@eliasm307

Description

@eliasm307

This example can be improved by applying the types defined in @scaleway/serverless-functions e.g.

import type { Handler } from "@scaleway/serverless-functions/framework/types/types";

export const handle: Handler = async (event, context, cb) => {
    return {
        body: "Hello world!",
        headers: { "Content-Type": ["application/json"] },
        statusCode: 200,
    };
};

The types from @scaleway/serverless-functions/framework/types/types could also be exposed at the package entry point so it can be simplified to:

import type { Handler } from "@scaleway/serverless-functions";

export const handle: Handler = async (event, context, cb) => {
    return {
        body: "Hello world!",
        headers: { "Content-Type": ["application/json"] },
        statusCode: 200,
    };
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions