Skip to content

Commit

Permalink
feat(nodejs): add stripe-paymetn-with-refund-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
m7moudGadallah committed Sep 20, 2024
1 parent 7e5b3f3 commit dd7b6c2
Show file tree
Hide file tree
Showing 94 changed files with 4,870 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nodejs/stripe-payment-with-refund-demo/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
docker-compose*
.prettierrc
.dockerignore
Dockerfile
.gitignore
11 changes: 11 additions & 0 deletions nodejs/stripe-payment-with-refund-demo/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NODE_ENV=development

PORT=3000

MONGO_URI=mongodb://root:example@mongo:27017/bookshop?authSource=admin

STRIPE_API_SECRET_KEY=<add_your_api_secret_key>
STRIPE_ENDPOINT_SECRET=<add_your_webhook_endpoint_secret>
STRIPE_WEBHOOK_URL=http://localhost:3000/stripe-webhook
CHECKOUT_SESSION_SUCCESS_URL=https://www.example.com/success
CHECKOUT_SESSION_CANCEL_URL=https://www.example.com/cancel
2 changes: 2 additions & 0 deletions nodejs/stripe-payment-with-refund-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
7 changes: 7 additions & 0 deletions nodejs/stripe-payment-with-refund-demo/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"singleQuote": true,
"semi": true,
"tabWidth": 2,
"arrowParens": "always",
"printWidth": 80
}
3 changes: 3 additions & 0 deletions nodejs/stripe-payment-with-refund-demo/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["prefs"]
}
16 changes: 16 additions & 0 deletions nodejs/stripe-payment-with-refund-demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# BASE IMAGE
FROM node:22-alpine

# SET WORKING DIRECTORY
WORKDIR /home/node/app

# COPY package.json
COPY package.json yarn.lock ./

# INSTALL DEPENDENCIES
RUN yarn install --ignore-optional

# EXPOSE PORT
EXPOSE 3000

CMD ["yarn", "run", "start"]
46 changes: 46 additions & 0 deletions nodejs/stripe-payment-with-refund-demo/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
services:
# Node.js
node-app:
build:
context: .
dockerfile: Dockerfile
ports:
- '3000:3000'
env_file:
- .env
volumes:
- './node_modules:/home/node/app/node_modules'
- '.:/home/node/app'
networks:
- my-net
depends_on:
- mongo

# MognoDB
mongo:
image: mongo
restart: always
ports:
- '27017:27017'
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
volumes:
- stripe-payment-mongo-demo-data:/data/db
networks:
- my-net

# Stripe CLI
stripe-cli:
image: stripe/stripe-cli
command: listen --forward-to ${STRIPE_WEBHOOK_URL}
env_file:
- .env
networks:
- my-net

networks:
my-net:

volumes:
stripe-payment-mongo-demo-data:
6 changes: 6 additions & 0 deletions nodejs/stripe-payment-with-refund-demo/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["src"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "npx ts-node --project ./tsconfig.json ./src/main.ts"
}
Loading

0 comments on commit dd7b6c2

Please sign in to comment.