swtc
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

SWTC - Start with Testcontainers

NPM Package Version CI License: MIT Typescript

A thin wrapper around the testcontainers library, SWTC lets you easily start and configure a network of Docker services before running a node project.

Installation

$ npm install swtc --save-dev

Configuration

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;

Usage

After a .swtc.ts file is configured, you can start your node process with the following command:

npx swtc

Documentation

Please refer to the SWTC Documentation for more information about setup and configuration.

Contributing

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE.md for more information.

Package Sidebar

Install

npm i swtc

Weekly Downloads

2

Version

2.1.0

License

MIT

Unpacked Size

10.2 kB

Total Files

15

Last publish

Collaborators

  • bradturner