diff --git a/.env.example b/.env.example index c0c68b1..56dc61b 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ -PORT=3000 \ No newline at end of file +PORT=3000 +NODE_ENV=development \ No newline at end of file diff --git a/.gitignore b/.gitignore index ea48d65..ec1803d 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,5 @@ lerna-debug.log* !.vscode/launch.json !.vscode/extensions.json -.env \ No newline at end of file +.env +*.pem \ No newline at end of file diff --git a/README.md b/README.md index 9fe8812..9b06b48 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,18 @@ -

- Nest Logo -

- -[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 -[circleci-url]: https://circleci.com/gh/nestjs/nest - -

A progressive Node.js framework for building efficient and scalable server-side applications.

-

-NPM Version -Package License -NPM Downloads -CircleCI -Coverage -Discord -Backers on Open Collective -Sponsors on Open Collective - - Support us - -

- +# Nest Starter App ## Description +A starter app with LTI1p0 enabled for NestJS -[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. +## Setup +Create a file in the root called `.env` and copy the contents of `.env.example` + +## SSL +Create a ssl key and certificate an place them in the root directory + +```bash +$ openssl req -x509 -newkey rsa:4096 -keyout private-key.pem -out public-cert.pem -sha256 -nodes +``` +Where this key will only be used for development you can leave all of the information blank. ## Installation diff --git a/package.json b/package.json index 7294bd0..bac5533 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "on-the-spot", + "name": "nest-starter-app", "version": "0.0.1", "description": "", "author": "", diff --git a/src/main.ts b/src/main.ts index 90ecef4..4483c3b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,11 +1,21 @@ import { config } from 'dotenv'; +import * as fs from 'fs'; import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; config(); async function bootstrap() { - const app = await NestFactory.create(AppModule); + let httpsOptions; + if (process.env.NODE_ENV === 'development') { + httpsOptions = { + key: fs.readFileSync('./private-key.pem'), + cert: fs.readFileSync('./public-cert.pem'), + } + } + const app = await NestFactory.create(AppModule, { + httpsOptions + }); await app.listen(process.env.PORT); } bootstrap();