Before starting local development, it is required to have Node.js installed in your system. Additionally, you will need to install the Nest.js CLI by running the following command:
npm install -g @nestjs/cli
The advantage of using the Nest.js CLI is that it helps to create, build, and manage your Nest.js projects easily and efficiently.
-
Copy contents of
.env.template
to a new file named.env
-
Run the following command:
Powershell:
./docker.ps1
Bash:
./docker.sh
-
Clone the repository
-
Open the cloned repository in Visual Studio Code
-
Copy contents of
.env.template
to a new file named.env
(if you not doing this the next step will be error) -
Click the "Remote-Containers: Open Folder in Container" command in the Command Palette (press
F1
to open the Command Palette) -
Wait for the container to start and for the application to be installed
-
Run the following command:
nest start --watch
The application will start in development mode, allowing you to make code changes and see the results in real-time. -
if you want to use git you need to use this command first
git config --global --add safe.directory /workspaces/sec33_Group4_BookBix_Backend
(and the vscode will suggest you to Manage Unsafe Repositories to use git in vscode)
The Stripe secret key is required to make API calls to the Stripe API, such as creating and updating customers, charges, and subscriptions. Here's how you can get your Stripe secret key:
-
Sign up for a Stripe account at https://dashboard.stripe.com/register.
-
Once you've signed up, navigate to the Developers section in your Stripe dashboard.
-
In the API keys section, you'll see your Test mode and Live mode secret keys. Copy the Test mode secret key (which starts with
sk_test_
) and set it as the value of theSTRIPE_SECRET_KEY
environment variable in your.env
file.STRIPE_SECRET_KEY=sk_test_..
If you don't have an
.env
file, create one in the root directory of your project. -
Use the
STRIPE_SECRET_KEY
environment variable to make API calls to the Stripe API.You can also find your Stripe secret key by navigating to https://dashboard.stripe.com/test/apikey, which will display your Test mode secret key. Make sure to keep your secret key secure and not share it with anyone.
Stripe provides a command-line interface (CLI) tool called listen
that lets you receive webhook events from Stripe and test your webhook handler locally. You can use the listen
command with the --forward-to
option to forward webhook events to a local endpoint, such as http://localhost:3001/stripe/webhook
.
Here are the steps to use the listen
command with a local webhook:
-
Install the Stripe CLI by following the instructions here.
-
Start your server on port
3001
and make sure it's accessible athttp://localhost:3001/stripe/webhook
. This endpoint will receive the webhook events from Stripe. -
Run the following command to start listening for webhook events:
stripe listen --forward-to http://localhost:3001/stripe/webhook
This command starts the webhook listener and forwards any events received from Stripe to the specified local endpoint.
-
When you run the
listen
command for the first time, Stripe generates a webhook signing secret for you. Copy this secret and set it as the value of theSTRIPE_WEBHOOK_SECRET
environment variable in your.env
file. If you don't have an.env
file, create one in the root directory of your project.STRIPE_WEBHOOK_SECRET=whsec_...
You can also find the webhook signing secret in your Stripe dashboard under Developers > Webhooks > Signing secret. Make sure to keep this secret secure and not share it with anyone.
- Nest.js
- MongoDB
- Docker
Do not modify the docker
file without proper understanding.