Skip to content

Commit

Permalink
refactor: dependency Upgrade, Dependency Fixes, Redis Cache and whole…
Browse files Browse the repository at this point in the history
… lot new utils and features
  • Loading branch information
itsdheerajbudhiraja committed Dec 17, 2024
1 parent b8feb8a commit 858100f
Show file tree
Hide file tree
Showing 66 changed files with 10,972 additions and 3,547 deletions.
52 changes: 48 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
NODE_ENV=production
HOST=0.0.0.0
PORT=3000
ENABLE_WEBSOCKET_SERVER=true
HTTPS=false
SSL_CRT_FILE=
SSL_KEY_FILE=
Expand All @@ -27,6 +28,7 @@ ADMIN_API_KEY=ADMIN_API_KEY
# Disable auth when handled on API GW
USE_BEARER_AUTH=true
USE_API_KEY_AUTH=true
USE_WEBSOCKET_AUTH=true

# Swagger
SWAGGER_BASE_URL=localhost
Expand All @@ -52,6 +54,10 @@ REDIS_CLUSTER_MODE=true
CACHE_TYPE=NodeCache
CACHE_STANDARD_TTL=604800
CACHE_EXPIRED_CHECK_PERIOD=600
CACHE_SERVER_URL=redis://localhost:6379/0

# Web Notification
NOTIFICATION_QUEUE=notifications

# Auth
AUTH_TYPE=JWT
Expand All @@ -60,18 +66,56 @@ JWT_EXPIRY_TIME=1h
JWT_REFRESH_TOKEN_EXPIRY_TIME=7d
JWT_AUDIENCES=JWT_AUDIENCE
JWT_ISSUER=http://localhost:3000
JWT_PII_ENCRYPTION_AES_KEY=
JWT_PII_ENCRYPTION_AES_IV=
AUTHENTICATION_SCHEME=Bearer
KEY_PAIR_DIRECTORY=keys # Relative to root directory of project
PRIVATE_KEY_FILE=privateKey.pem
PUBLIC_KEY_FILE=publicKey.pem
PRIVATE_PEM_KEY=privateKey # RSA Public key for jwt will go here
PUBLIC_PEM_KEY=publicKey # RSA Public key for jwt will go here

# Banner
APPLICATION_TITLE=Express Server
APPLICATION_DESCRIPTION=Sample Typescript Express Server
APPLICATION_TITLE_COLOR=mediumaquamarine
APPLICATION_DESCRIPTION_COLOR=cyan

# Scripts
SCRIPT_SERVER_BASE_URL=http://localhost:3000
SCRIPT_SERVER_API_KEY=ADMIN_API_KEY

# Email validation TLDS
EMAIL_VALIDATOR_ADDITIONAL_TLDS=,
EMAIL_VALIDATOR_ADDITIONAL_SLDS=,
EMAIL_VALIDATOR_ADDITIONAL_DOMAINS=,
EMAIL_VALIDATOR_ADDITIONAL_DOMAINS=,

# SMTP
SMTP_HOST=email-smtp.ap-south-1.amazonaws.com
SMTP_PORT=587
SMTP_USERNAME=
SMTP_PASS=
SMTP_SENDER_NAME=Express Boilerplate
SMTP_SENDER_EMAIL=no-reply@express-boilerplate.com
CC_MAIL=

# AWS S3 Buckets configurations
AWS_REGION=ap-south-1
AWS_ACCESS_ID=
AWS_ACCESS_KEY=
AWS_S3_BUCKET_NAME=s3-bucket-name
AWS_S3_ENCRYPT_DOCUMENTS=true
AWS_S3_ENCRYPTION_KEY=
AWS_S3_ENCRYPTED_DOCUMENT_DOWNLOAD_BASE_URL=
AWS_S3_ENCRYPTED_DOCUMENT_DOWNLOAD_HMAC_SECRET_KEY=

# Document Image Size Limits
DOCUMENT_GENERAL_MAX_SIZE=3072
DOCUMENT_JPEG_MAX_SIZE=500
DOCUMENT_PNG_MAX_SIZE=2048
DOCUMENT_PDF_MAX_SIZE=3072

## Other Components configurations like Dedicated Login Service etc

# Login service
COOKIES_DOMAIN=localhost
COOKIES_NAME_SUFFIX=
LOGIN_JWKS_ENDPOINT=
LOGIN_SERVICE_BASE_URL=
56 changes: 50 additions & 6 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
NODE_ENV=production
HOST=0.0.0.0
PORT=3000
ENABLE_WEBSOCKET_SERVER=true
HTTPS=false
SSL_CRT_FILE=
SSL_KEY_FILE=
Expand All @@ -27,6 +28,7 @@ ADMIN_API_KEY=ADMIN_API_KEY
# Disable auth when handled on API GW
USE_BEARER_AUTH=true
USE_API_KEY_AUTH=true
USE_WEBSOCKET_AUTH=true

# Swagger
SWAGGER_BASE_URL=localhost
Expand All @@ -52,6 +54,10 @@ REDIS_CLUSTER_MODE=true
CACHE_TYPE=NodeCache
CACHE_STANDARD_TTL=604800
CACHE_EXPIRED_CHECK_PERIOD=600
CACHE_SERVER_URL=redis://localhost:6379/0

# Web Notification
NOTIFICATION_QUEUE=notifications

# Auth
AUTH_TYPE=JWT
Expand All @@ -60,18 +66,56 @@ JWT_EXPIRY_TIME=1h
JWT_REFRESH_TOKEN_EXPIRY_TIME=7d
JWT_AUDIENCES=JWT_AUDIENCE
JWT_ISSUER=http://localhost:3000
JWT_PII_ENCRYPTION_AES_KEY=
JWT_PII_ENCRYPTION_AES_IV=
AUTHENTICATION_SCHEME=Bearer
KEY_PAIR_DIRECTORY=keys # Relative to root directory of project
PRIVATE_KEY_FILE=privateKey.pem
PUBLIC_KEY_FILE=publicKey.pem
PRIVATE_PEM_KEY=privateKey # RSA Public key for jwt will go here
PUBLIC_PEM_KEY=publicKey # RSA Public key for jwt will go here

# Banner
APPLICATION_TITLE=Express Server
APPLICATION_DESCRIPTION=Sample Typescript Express Server
APPLICATION_TITLE_COLOR=mediumaquamarine
APPLICATION_DESCRIPTION_COLOR=cyan

# Scripts
SCRIPT_SERVER_BASE_URL=http://localhost:3000
SCRIPT_SERVER_API_KEY=ADMIN_API_KEY

# Email validation TLDS
EMAIL_VALIDATOR_ADDITIONAL_TLDS=[]
EMAIL_VALIDATOR_ADDITIONAL_SLDS=[]
EMAIL_VALIDATOR_ADDITIONAL_DOMAINS=[]
EMAIL_VALIDATOR_ADDITIONAL_TLDS=,
EMAIL_VALIDATOR_ADDITIONAL_SLDS=,
EMAIL_VALIDATOR_ADDITIONAL_DOMAINS=,

# SMTP
SMTP_HOST=email-smtp.ap-south-1.amazonaws.com
SMTP_PORT=587
SMTP_USERNAME=
SMTP_PASS=
SMTP_SENDER_NAME=Express Boilerplate
SMTP_SENDER_EMAIL=no-reply@express-boilerplate.com
CC_MAIL=

# AWS S3 Buckets configurations
AWS_REGION=ap-south-1
AWS_ACCESS_ID=
AWS_ACCESS_KEY=
AWS_S3_BUCKET_NAME=s3-bucket-name
AWS_S3_ENCRYPT_DOCUMENTS=true
AWS_S3_ENCRYPTION_KEY=
AWS_S3_ENCRYPTED_DOCUMENT_DOWNLOAD_BASE_URL=
AWS_S3_ENCRYPTED_DOCUMENT_DOWNLOAD_HMAC_SECRET_KEY=

# Document Image Size Limits
DOCUMENT_GENERAL_MAX_SIZE=3072
DOCUMENT_JPEG_MAX_SIZE=500
DOCUMENT_PNG_MAX_SIZE=2048
DOCUMENT_PDF_MAX_SIZE=3072

## Other Components configurations like Dedicated Login Service etc

# Login service
COOKIES_DOMAIN=localhost
COOKIES_NAME_SUFFIX=
LOGIN_JWKS_ENDPOINT=
LOGIN_SERVICE_BASE_URL=
7 changes: 0 additions & 7 deletions .eslintignore

This file was deleted.

50 changes: 0 additions & 50 deletions .eslintrc

This file was deleted.

3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
npm run build
3 changes: 0 additions & 3 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

exec < /dev/tty && npx cz --hook || true
27 changes: 15 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20.12.0
FROM node:22.12.0

# Add a new user "nodeapp"
RUN useradd nodeapp
Expand All @@ -7,29 +7,32 @@ RUN useradd nodeapp
WORKDIR /home/nodeapp/

# Copy required artifacts
COPY package.json ./package.json
COPY package-lock.json ./package-lock.json
COPY --chown=nodeapp:nodeapp package.json ./package.json
COPY --chown=nodeapp:nodeapp package-lock.json ./package-lock.json

# Installing node modules
RUN npm install

# Copy code
COPY tsconfig.json ./tsconfig.json
COPY tsoa.json ./tsoa.json
COPY swagger.json ./swagger.json
COPY keys ./keys
COPY src ./src
COPY .env ./.env
COPY --chown=nodeapp:nodeapp tsconfig.json ./tsconfig.json
COPY --chown=nodeapp:nodeapp tsoa.json ./tsoa.json
COPY --chown=nodeapp:nodeapp swagger.json ./swagger.json
COPY --chown=nodeapp:nodeapp keys ./keys
COPY --chown=nodeapp:nodeapp src ./src
COPY --chown=nodeapp:nodeapp .env ./.env

# Building code
RUN npm run build

# Updating swagger
RUN npm run swagger

# Updating typedocs
RUN npm run doc

# Copy files for test
COPY .env.test ./.env.test
COPY jest.config.ts ./jest.config.ts
COPY --chown=nodeapp:nodeapp .env.test ./.env.test
COPY --chown=nodeapp:nodeapp jest.config.ts ./jest.config.ts

# Running test cases
RUN npm test
Expand All @@ -46,4 +49,4 @@ USER nodeapp
# Preventing swagger from comments being ovveridden because we deleted src folder
ENV UPDATE_SWAGGER_ON_START=false

CMD [ "npm", "run", "prod" ]
CMD [ "node", "--enable-source-maps", "dist/index.js" ]
29 changes: 16 additions & 13 deletions Dockerfile.rust-wasm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20.12.0
FROM node:22.12.0

# Add a new user "nodeapp"
RUN useradd nodeapp
Expand All @@ -16,9 +16,9 @@ RUN cargo install wasm-pack
WORKDIR /home/nodeapp/

# Copy required artifacts
COPY package.json ./package.json
COPY package-lock.json ./package-lock.json
COPY rust-wasm-libs ./rust-wasm-libs
COPY --chown=nodeapp:nodeapp package.json ./package.json
COPY --chown=nodeapp:nodeapp package-lock.json ./package-lock.json
COPY --chown=nodeapp:nodeapp rust-wasm-libs ./rust-wasm-libs

# Installing node modules
RUN npm install --force
Expand All @@ -28,22 +28,25 @@ RUN npm run build-rust-wasm
RUN npm i --save ./rust-wasm-libs/pkg --force

# Copy code
COPY tsconfig.json ./tsconfig.json
COPY tsoa.json ./tsoa.json
COPY swagger.json ./swagger.json
COPY keys ./keys
COPY src ./src
COPY .env.local ./.env
COPY --chown=nodeapp:nodeapp tsconfig.json ./tsconfig.json
COPY --chown=nodeapp:nodeapp tsoa.json ./tsoa.json
COPY --chown=nodeapp:nodeapp swagger.json ./swagger.json
COPY --chown=nodeapp:nodeapp keys ./keys
COPY --chown=nodeapp:nodeapp src ./src
COPY --chown=nodeapp:nodeapp .env.local ./.env

# Building code
RUN npm run build

# Updating swagger
RUN npm run swagger

# Updating typedocs
RUN npm run doc

# Copy files for test
COPY .env.test ./.env.test
COPY jest.config.ts ./jest.config.ts
COPY --chown=nodeapp:nodeapp .env.test ./.env.test
COPY --chown=nodeapp:nodeapp jest.config.ts ./jest.config.ts

# Running test cases
RUN npm test
Expand All @@ -59,4 +62,4 @@ USER nodeapp
# Preventing swagger from comments being ovveridden because we deleted src folder
ENV UPDATE_SWAGGER_ON_START=false

CMD [ "npm", "run", "prod" ]
CMD [ "node", "--enable-source-maps", "dist/index.js" ]
Loading

0 comments on commit 858100f

Please sign in to comment.