Giter VIP home page Giter VIP logo

Comments (5)

zacanger avatar zacanger commented on April 28, 2024 2

This change (the one referenced in your issue on the @types repo) was incorrect. Returning a function that returns a promise isn't the same as returning a Promise. It looks like the original change mentions that issue, but the current version of the types on npm is still incorrect.

from koa.

crystalfp avatar crystalfp commented on April 28, 2024

In the meantime added issue to DefinitelyTyped @types/koa module DefinitelyTyped/DefinitelyTyped#64923

from koa.

younes-io avatar younes-io commented on April 28, 2024

@crystalfp did you try something like this

import http2 from "node:http2";
import fs from "node:fs";

import Koa from "koa";

const options = {
  key: fs.readFileSync("./cert/localhost-privkey.pem"),
  cert: fs.readFileSync("./cert/localhost-cert.pem"),
};
const port = 3322;

const runApp = () => {
  console.log("Running");
};
const handleServerErrors = (error) => {
  console.log("Error", error);
};

const app = new Koa();
const startServer = async () => {
  const server = http2.createSecureServer(options, app.callback());
  server.listen(port, () => runApp()).once("error", handleServerErrors);
};

startServer();

from koa.

crystalfp avatar crystalfp commented on April 28, 2024

This is exactly my code (also in my first question BTW). The problem is the typing of app.callback() not the code.

from koa.

3imed-jaberi avatar 3imed-jaberi commented on April 28, 2024

@crystalfp This should be fixed on the @types/koa side.

I am not sure but maybe wrapping the callback method on another anonymous function like () => { app.callback() } be work.

from koa.

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.