Git Product home page Git Product logo

Comments (4)

dougmoscrop avatar dougmoscrop commented on August 16, 2024 1

I don't think another approach is needed, updating the union makes sense. I didn't write the types, it was a community contribution.

from serverless-http.

logusgraphics avatar logusgraphics commented on August 16, 2024

This works for me:

const { createServer } = require('http');
const serverless = require('serverless-http');

const server = createServer(async (req, res) => {
    res.statusCode = 200;
    res.end('Hello serverless world!'); 
});

exports.handler = serverless(server, { provider: 'aws' });

from serverless-http.

vorant94 avatar vorant94 commented on August 16, 2024

This works for me:

const { createServer } = require('http');
const serverless = require('serverless-http');

const server = createServer(async (req, res) => {
    res.statusCode = 200;
    res.end('Hello serverless world!'); 
});

exports.handler = serverless(server, { provider: 'aws' });

you are writing JS, but I tried to use with TS so I got type error... maybe the code is fine, only types are not reflecting it as they shouldπŸ€”

from serverless-http.

vorant94 avatar vorant94 commented on August 16, 2024

still no response from someone of maintainers... is this repo open source just for the sake of being open source (which is totally valid by the way) or authors meant to communicate with the community and so on?

I also see tests that should cover integration with node built-in http module, so the problem is really with types only. I am happy to contribute, but i'd like to get feedback on whether it is needed or not at all... despite what is written in readme about contribution there are opened pr's from 2021...

regarding the issue itself. I see the type that handler accepts type Application = Function | Partial<FrameworkApplication>. The easiest way to fix the issue is to add Server<typeof IncomingMessage, typeof ServerResponse> to the union and the type gymnastic is done, but since you are not iterating in this union over all possible integrations, I assume you'd prefer some another approach...

from serverless-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.