I did not find in the documentation how to do this. If it is still possible, how to do it?
Hey thanks for the issue, I must say that I never that of that issue.
I think it could work with something like this: (not tested!)
import * as bodyParser from 'body-parser';
import * as fs from 'fs';
import * as http from 'http';
import * as https from 'https';
import { Container } from 'inversify';
import { interfaces, InversifyExpressServer, TYPE } from 'inversify-express-utils';
// replace this with your private key
const privateKey = fs.readFileSync('sslcert/server.key', 'utf8');
// replace this with you certificate
const certificate = fs.readFileSync('sslcert/server.crt', 'utf8');
const credentials = {key: privateKey, cert: certificate};
// set up container
let container = new Container();
// note that you *must* bind your controllers to Controller
container.bind<interfaces.Controller>(TYPE.Controller).to(FooController).whenTargetNamed('FooController');
container.bind<FooService>('FooService').to(FooService);
// create server
let server = new InversifyExpressServer(container);
server.setConfig((app) => {
// config for express
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
});
let app = server.build();
// create the http server
const httpServer = http.createServer(app);
// create the https server
const httpsServer = https.createServer(credentials, app);
httpServer.listen(8080);
httpsServer.listen(8443);
Please let me know if this helps :)
Have a nice day.
@lholznagel Thanks, this works great!
@lholznagel Is there a way to create HttpServer without using inversify-express-utils ?
@esakkikrishnan if you only want to use expressjs remove all the inversify-express-utils and replace let app = server.build(); with let app = express()
Most helpful comment
Hey thanks for the issue, I must say that I never that of that issue.
I think it could work with something like this: (not tested!)
Please let me know if this helps :)
Have a nice day.