add https and pem files (for anyone to use, fast setup)

This commit is contained in:
Ben Wilson
2023-08-03 17:16:16 -04:00
parent a7ea61f28f
commit a7b73b0610
6 changed files with 64 additions and 7 deletions
+8 -2
View File
@@ -3,6 +3,7 @@ import { NestFactory } from '@nestjs/core';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import * as bitcoinjs from 'bitcoinjs-lib';
import { useContainer } from 'class-validator';
import { readFileSync } from 'fs';
import * as ecc from 'tiny-secp256k1';
import { AppModule } from './app.module';
@@ -14,8 +15,12 @@ async function bootstrap() {
return;
}
const httpsOptions = {
key: readFileSync('./secrets/key.pem'),
cert: readFileSync('./secrets/cert.pem'),
};
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter({ https: httpsOptions }));
app.setGlobalPrefix('api')
app.useGlobalPipes(
new ValidationPipe({
@@ -28,11 +33,12 @@ async function bootstrap() {
app.enableCors();
useContainer(app.select(AppModule), { fallbackOnErrors: true });
//Taproot
bitcoinjs.initEccLib(ecc);
await app.listen(process.env.PORT, '0.0.0.0', () => {
console.log(`http listening on port ${process.env.PORT}`);
console.log(`https listening on port ${process.env.PORT}`);
});
}