Variable Name | Description | Default value |
---|---|---|
NODE_COUCHBASE_CONNECTION_STRING | A couchbase connection string | - |
NODE_COUCHBASE_USERNAME | Username for authentication with Couchbase | - |
NODE_COUCHBASE_PASSWORD | Password for authentication with Couchbase | - |
COUCHBASE_USE_CAPELLA | Use to change the connection profile | false |
COUCHBASE_DEFAULT_BUCKET | The name of the Couchbase Bucket, parent of the scope | default |
COUCHBASE_DEFAULT_SCOPE | The name of the Couchbase scope, parent of the collection | _default |
COUCHBASE_DEFAULT_COLLECTION | The name of the Couchbase collection to store the Documents | _default |
COUCHBASE_OTLP_ENABLED | Enable traces and metrics OTLP export | false |
COUCHBASE_OTLP_ENDPOINT | The OTLP server endpoint to send metrics and traces | - |
Follow these steps to get the starter kit up and running on your local machine.
Prerequisites
Make sure you have the following installed:
- Node.js
You will also need an account on Couchbase Capella to create a cluster and obtain the connection details.
Clone the repository
git clone https://github.com/couchbase-starter-kit/couchbase-node-starter.git
cd URL
Install dependencies
npm install
Configure Couchbase Credentials
Copy the .env.sample
file in the root directory of the project and rename it to .env
. Update the .env
file with your Couchbase credentials as follows:
NODE_COUCHBASE_CONNECTION_STRING=
NODE_COUCHBASE_USERNAME=
NODE_COUCHBASE_PASSWORD=
COUCHBASE_USE_CAPELLA=
COUCHBASE_DEFAULT_BUCKET=default
COUCHBASE_DEFAULT_SCOPE=_default
COUCHBASE_DEFAULT_COLLECTION=_default
COUCHBASE_OTLP_ENABLED=false
COUCHBASE_OTLP_ENDPOINT=
You can obtain those credentials by first creating an account on Couchbase Capella at https://cloud.couchbase.com/ and then creating a database called node_starter_app
. Inside the database, create a bucket. The name of the bucket is what you should use for the COUCHBASE_DEFAULT_BUCKET
environment variable (for now this is hardcoded).
Once you have done so, you can navigate to the Connect
tab in the database and copy the connection string URL. This is what you should use for the NODE_COUCHBASE_CONNECTION_STRING
environment variable. You will also need to create a user with the appropriate permissions and use the username and password for the NODE_COUCHBASE_USERNAME
and NODE_COUCHBASE_PASSWORD
environment variables.
Running the Test Suite
This application includes the beginnings of a test suite using Jest. To run the test suite, use the following command:
npx jest
This will run all the tests and output the results in the terminal. You can run any specific test file by passing the file path as an argument to the npx test
command, as follows:
npx test -- something.test.js
Starting the Application
To start the application, run the following command:
npm run start
This will start the [Node.js] server, and the command will run automatically showing the results in the command line.
Thank you to Codercatdev for creating this starter kit and contributing to the Couchbase Node.js community!
Contributions are more than welcome! If you encounter any bugs or issues with the application, please open an issue on the GitHub repository. If you would like to contribute code, feel free to open a pull request with your changes. All contributors are expected to follow the Code of Conduct.
This project is licensed under the MIT License - see the LICENSE file for details.