Skip to content

Instantly share code, notes, and snippets.

@jhfgloria
Created August 4, 2023 15:51
Show Gist options
  • Select an option

  • Save jhfgloria/03fc285f248a519ba68a4f24db0be4bf to your computer and use it in GitHub Desktop.

Select an option

Save jhfgloria/03fc285f248a519ba68a4f24db0be4bf to your computer and use it in GitHub Desktop.
Complete one-off entrypoint
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