-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Daniel Karnutsch <[email protected]> Co-authored-by: Niko Sams <[email protected]>
- Loading branch information
1 parent
4d410a3
commit 1ba83a9
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,5 @@ junit.xml | |
/uploads | ||
|
||
src/site-configs.d.ts | ||
|
||
.nestjs_repl_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import "tsconfig-paths/register"; | ||
|
||
import { MikroORM } from "@mikro-orm/core"; | ||
import { NestFactory } from "@nestjs/core"; | ||
import { repl } from "@nestjs/core/repl"; | ||
import { NestExpressApplication } from "@nestjs/platform-express"; | ||
|
||
import { AppModule } from "./app.module"; | ||
import { createConfig } from "./config/config"; | ||
|
||
async function bootstrap() { | ||
if (process.env.NODE_ENV === "production") { | ||
throw new Error("Can't use REPL in production"); | ||
} | ||
|
||
const config = createConfig(process.env); | ||
const appModule = AppModule.forRoot(config); | ||
const app = await NestFactory.create<NestExpressApplication>(appModule); | ||
const replServer = await repl(appModule); | ||
|
||
// preserve history between refreshes of the repl | ||
replServer.setupHistory(".nestjs_repl_history", (err) => { | ||
if (err) { | ||
console.error(err); | ||
} | ||
}); | ||
|
||
// Get the MikroORM instance from the app | ||
const orm = app.get(MikroORM); | ||
|
||
// Context shortcuts | ||
const replContext = replServer.context; | ||
replContext.orm = orm; | ||
replContext.em = orm.em; | ||
} | ||
bootstrap(); |