Created
August 4, 2023 15:51
-
-
Save jhfgloria/03fc285f248a519ba68a4f24db0be4bf to your computer and use it in GitHub Desktop.
Complete one-off entrypoint
This file contains hidden or 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
| import { NestFactory } from '@nestjs/core'; | |
| import { OneOffModule } from './one-off.module'; | |
| import * as Executables from './one-offs'; | |
| async function oneOff() { | |
| const klass = process.argv[2]; | |
| const application = await NestFactory.createApplicationContext(OneOffModule); | |
| const oneOff = application.get(Executables[klass]); | |
| try { | |
| await oneOff.run(); | |
| } catch (error) { | |
| console.error(error); | |
| } | |
| await application.close(); | |
| } | |
| oneOff().catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment