Closed Julien-Broyard closed 5 years ago
Hi @tomc974, can we kindly ask for your support here?
Best Regards.
@Julien-Broyard Hi! When calling restana
you have to specify which protocol you are using. So if you change your function call to restana<restana.Protocol.HTTP2>
, it should work.
Hi !
I've tried it however it don't work
import https from "https";
import pem from "pem";
import restana from "restana";
pem.createCertificate({ days: 1, selfSigned: true }, async (err, keys) => {
try {
if (err) console.error(err);
const service = await restana<restana.Protocol.HTTPS>({
server: https.createServer({
cert: keys.certificate,
key: keys.clientKey
})
});
service.get("/", (req, res) => {
res.send(req.url);
});
await service.start(8080);
} catch (error) {
console.error(error);
}
});
Argument of type '{ server: Server; }' is not assignable to parameter of type 'Options<Protocol.HTTPS>'.
Property 'errorHandler' is missing in type '{ server: Server; }' but required in type 'Options<Protocol.HTTPS>'.ts(2345)
index.d.ts(124, 5): 'errorHandler' is declared here.
import http2 from "http2";
import pem from "pem";
import restana from "restana";
pem.createCertificate({ days: 1, selfSigned: true }, async (err, keys) => {
try {
if (err) console.error(err);
const service = await restana<restana.Protocol.HTTP2>({
server: http2.createSecureServer({
cert: keys.certificate,
key: keys.clientKey
})
});
service.get("/", (req, res) => {
res.send(req.url);
});
await service.start(8080);
} catch (error) {
console.error(error);
}
});
Argument of type '{ server: Http2SecureServer; }' is not assignable to parameter of type 'Options<Protocol.HTTP2>'.
Property 'errorHandler' is missing in type '{ server: Http2SecureServer; }' but required in type 'Options<Protocol.HTTP2>'.ts(2345)
index.d.ts(124, 5): 'errorHandler' is declared here.
My bad I've just realized that I needed to add the errorHandler property to restana options !
My bad I've just realized that I needed to add the errorHandler property to restana options !
The errorHandler property should be optional. Will fix it ASAP.
Anyway glad that you could move forward. Thanks @tomc974 for your support!
Hi @Julien-Broyard, errorHandler
config is not required anymore in restana@3.0.2
. You should be fine now.
Regards and thanks.
While trying to use restana with http2/https with typescript I've got some errors.
Here's the code :
Here's the error :
Here's the code for the https :
Here's the error :
Here's my tsconfig :