A thin wrapper around the testcontainers library, SWTC lets you easily start and configure a network of Docker services before running a node project.
$ npm install swtc --save-dev
After installing SWTC, you will need to create a .swtc.ts
file. This is the location where you can define what services are required before starting your NodeJS entrypoint.
import { GenericContainer, type SwtcConfig } from 'swtc';
const config: SwtcConfig = {
watch: true,
entrypoint: './server.ts',
containers: [
new GenericContainer('mongo').withExposedPorts(27017).onStart((instance) => {
process.env.DB_URI = `mongodb://${instance.getHost()}:${instance.getMappedPort(27017)}`;
}),
],
};
export default config;
After a .swtc.ts
file is configured, you can start your node process with the following command:
npx swtc
Please refer to the SWTC Documentation for more information about setup and configuration.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE.md
for more information.
Generated using TypeDoc