Skip to content

Commit

Permalink
feat(api): repl mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kuizuo committed Nov 17, 2023
1 parent 5283bc0 commit c486e68
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apps/api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ lerna-debug.log*
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

.nestjs_repl_history
3 changes: 2 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build": "nest build",
"dev": "npm run start",
"dev:debug": "npm run start:debug",
"start": "cross-env NODE_ENV=development nest start -w --path tsconfig.json -- ",
"repl": "npm run start -- --entryFile repl",
"start": "cross-env NODE_ENV=development nest start -w --path tsconfig.json",
"start:debug": "cross-env NODE_ENV=development nest start --debug --watch",
"start:prod": "cross-env NODE_ENV=production node dist/src/main",
"prod": "cross-env NODE_ENV=production pm2-runtime start ecosystem.config.js",
Expand Down
13 changes: 13 additions & 0 deletions apps/api/src/repl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { repl } from '@nestjs/core'

import { AppModule } from './app.module'

async function bootstrap() {
const replServer = await repl(AppModule)
replServer.setupHistory('.nestjs_repl_history', (err) => {
if (err) {
console.error(err)
}
})
}
bootstrap()

0 comments on commit c486e68

Please sign in to comment.