This project is based on backend of bugtracker software and is used as a service in SSTORAGE project, NodeJS in backend and MongoDB as a database. It contains complete authentication, user management system and subscription management.
- complete-authentication branch (v1.0.4) contains authentication & user management system.
- complete-authentication-subscription branch (v1.0.5) contains authentication, user management system and subscription management.
- Node version: 18.19.0
- NPM version: 10.2.3
Take reference from .env.example file.
- Create .env.local.dev and .env.local.staging for development.
- Create .env.deploy.production and .env.deploy.staging for serverless deployments.
- MongoDB atlas production database:
- .env.deploy.production (
npm run serverless-deploy-production)
- .env.deploy.production (
- MongoDB atlas staging database:
- .env.deploy.staging (
npm run serverless-deploy-staging) - .env.local.staging (
npm start)
- .env.deploy.staging (
- MongoDB local server:
- .env.local.dev (
npm run dev)
- .env.local.dev (
Run $ npm run dev to run the app in development for local mongodb server.
Run $ npm start to run the app in development for staging mongodb server in mongodb atlas.
Make sure serverless is installed npm i -g serverless and configured serverless config credentials --provider aws --key <Key> --secret <Secret>
To generate keys you can refer here https://www.youtube.com/watch?v=D5_FHbdsjRc
npm run serverless-deploy-staging
npm run serverless-deploy-production
In browser run the following: http://<server_link>/v0/working
- For M1/M2 based computer:
$ docker buildx build --platform linux/amd64 -t app .For Intel based computer:$ docker build -t app . - To try run container locally
$ docker run --rm -d -p 3000:8080 --name app-container app - To stop container
$ docker stop app-container
ENV=local.docker
PORT=3001
ENABLE_DEBUG=true
ENABLE_EMAIL=false
MONGODB_URL=mongodb://db:27017/sharedstorage
SENDGRID_API_KEY=#####
TOKEN_SECRET=ThisIsSecret
TOKEN_EXPIRY=1h
BACKEND_URL=http://localhost:3001
FRONTEND_URL=http://localhost:3000
CLOUD_SECRET_KEY=#####
CLOUD_ACCESS_KEY_ID=#####
MULTER_S3_BUCKET=sharedstorage-storage
STRIPE_PUBLISHABLE_KEY=#####
STRIPE_SECRET=#####
https://www.youtube.com/watch?v=NZElg91l_ms
Bucket policy
{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicRead", "Effect": "Allow", "Principal": "", "Action": [ "s3:GetObject", "s3:GetObjectVersion" ], "Resource": "arn:aws:s3:::bucket_name/" } ] }
CORS policy in bucket
[ { "AllowedHeaders": [ "" ], "AllowedMethods": [ "GET", "POST", "DELETE" ], "AllowedOrigins": [ "" ], "ExposeHeaders": [], "MaxAgeSeconds": 3000 } ]
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "s3:PutObject", "s3:GetObject" ], "Resource": "arn:aws:s3:::breadbutterstorage/*" } ] }
https://www.youtube.com/watch?v=1IjTYzOfSMc
$ npm install -g serverless
$ serverless config credentials --provider aws --key <KEY> --secret <SECRET>
$ serverless create -t aws-nodejs
$ npm install --save serverless-http
"pending", "accepted" and "declined"