Skip to content

Commit

Permalink
added https certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
sahalali committed Apr 19, 2024
1 parent faa57b7 commit 9df8715
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/deploy-to-test-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ jobs:
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Create secret key files
run: |
mkdir -p secrets
echo "${{ secrets.AWS_PRIVATE_KEY }}" | base64 -d >> secrets/private-key.pem
echo "${{ secrets.PUBLIC_CERTIFICATE_PEM}}" | base64 -d >> secrets/public-certificate.pem
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
Expand Down
5 changes: 5 additions & 0 deletions src/config/system.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ const { env } = process;
export const ARTSDATA: { ENDPOINT: string } = {
ENDPOINT: env.ARTSDATA_ENDPOINT || "https://db.artsdata.ca/"
};

export const APPLICATION = {
HTTP_PORT: Number(env.APP_PORT) || 3000,
HTTPS_PORT: Number(env.APP_PORT) || 3000
};
24 changes: 22 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import { NestFactory } from "@nestjs/core";
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
import { ExpressAdapter } from "@nestjs/platform-express";
import { AppModule } from "./app.module";
import { APPLICATION } from "./config/system.config";
import * as express from "express";
import * as fs from "fs";
import * as http from "http";
import * as https from "https";



async function bootstrap() {
const app = await NestFactory.create(AppModule);
const httpsOptions = {
key: fs.readFileSync("./secrets/private-key.pem"),
cert: fs.readFileSync("./secrets/public-certificate.pem")
};

const server = express();
const app = await NestFactory.create(
AppModule,
new ExpressAdapter(server)
);

const config = new DocumentBuilder()
.setTitle("Artsdata.ca Reconciliation Service")
Expand All @@ -13,7 +30,10 @@ async function bootstrap() {
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup("api", app, document);

await app.listen(3000);
await app.init();
// http.createServer(server).listen(APPLICATION.HTTP_PORT);
https.createServer(httpsOptions, server).listen(APPLICATION.HTTPS_PORT);

}

bootstrap();

0 comments on commit 9df8715

Please sign in to comment.