From d81351dc438e5e504a45ecfb35035d69f4d62405 Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 18 Jun 2024 19:46:51 +0000 Subject: [PATCH 01/15] initial Dockerfile --- Dockerfile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f10cd36 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +# Use an appropriate base image with Debian +FROM ubuntu:22.04 + +# Install Boost C++ Libraries and necessary tools +RUN apt-get update && \ + apt-get install -y libboost-all-dev insserv nano curl + +# Install Node.js and npm +RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \ + apt-get install -y nodejs + +# Copy the inCompass SDK package to the container +COPY docs/gcf1-global_3.1.0-2_ubuntu22.04-amd64.debb /tmp/ + +# Install the inCompass SDK +RUN dpkg -i /tmp/gcf1-global_3.1.0-2_ubuntu22.04-amd64.deb || apt-get install -y -f + +# Copy init script for the service and daemonize +RUN cp -p /usr/local/gcf1/sbin/gcf1 /etc/init.d/ && \ + insserv gcf1 + +# Configure the SDK +RUN sed -i 's|FC_DL_PATH=.*|FC_DL_PATH=/dl104/get.cgi|' /usr/local/gcf1/etc/gcf1.conf && \ + sed -i 's|FC_DL_PATH_SMALLDB=.*|FC_DL_PATH_SMALLDB=/dls104/get.cgi|' /usr/local/gcf1/etc/gcf1.conf && \ + sed -i 's|FC_PLACE=.*|FC_PLACE=blackdice|' /usr/local/gcf1/etc/gcf1.conf && \ + sed -i 's|FC_LICENCE=.*|FC_LICENCE=GD2LHJ98B4|' /usr/local/gcf1/etc/gcf1.conf && \ + sed -i 's|FC_EMAIL=.*|FC_EMAIL={any blackdice email address}|' /usr/local/gcf1/etc/gcf1.conf && \ + sed -i 's|HYBRID_ENABLE=.*|HYBRID_ENABLE=1|' /usr/local/gcf1/etc/gcf1.conf && \ + sed -i 's|HYBRID_NS_ACCESS=.*|HYBRID_NS_ACCESS=andkWEzbBWRR2K6iw4edRvfd6MmNNjRx|' /usr/local/gcf1/etc/gcf1.conf && \ + sed -i 's|HYBRID_USER_AGENT=.*|HYBRID_USER_AGENT=CSUX_blackdice|' /usr/local/gcf1/etc/gcf1.conf + +# Copy the Node.js application to the container +RUN mkdir /srv + +WORKDIR /srv + +COPY . . + +# Install Node.js dependencies +RUN npm install + +# Expose necessary ports (if any) +EXPOSE 3000/udp + +# Command to start the service and Node.js application +CMD ["/bin/bash", "-c", "/usr/local/gcf1/sbin/gcf1 start && npm start"] \ No newline at end of file From 267154e62a08560e6a40f67d4226ac9e801dc9ef Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 18 Jun 2024 20:34:06 +0000 Subject: [PATCH 02/15] updated dockerfile --- Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index f10cd36..12697ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,21 +3,20 @@ FROM ubuntu:22.04 # Install Boost C++ Libraries and necessary tools RUN apt-get update && \ - apt-get install -y libboost-all-dev insserv nano curl + apt-get install -y libboost-all-dev nano curl # Install Node.js and npm RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \ apt-get install -y nodejs # Copy the inCompass SDK package to the container -COPY docs/gcf1-global_3.1.0-2_ubuntu22.04-amd64.debb /tmp/ +COPY docs/gcf1-global_3.1.0-2_ubuntu22.04-amd64.deb /tmp/ # Install the inCompass SDK RUN dpkg -i /tmp/gcf1-global_3.1.0-2_ubuntu22.04-amd64.deb || apt-get install -y -f # Copy init script for the service and daemonize -RUN cp -p /usr/local/gcf1/sbin/gcf1 /etc/init.d/ && \ - insserv gcf1 +RUN cp -p /usr/local/gcf1/sbin/gcf1 /etc/init.d/ # Configure the SDK RUN sed -i 's|FC_DL_PATH=.*|FC_DL_PATH=/dl104/get.cgi|' /usr/local/gcf1/etc/gcf1.conf && \ @@ -30,7 +29,6 @@ RUN sed -i 's|FC_DL_PATH=.*|FC_DL_PATH=/dl104/get.cgi|' /usr/local/gcf1/etc/gcf1 sed -i 's|HYBRID_USER_AGENT=.*|HYBRID_USER_AGENT=CSUX_blackdice|' /usr/local/gcf1/etc/gcf1.conf # Copy the Node.js application to the container -RUN mkdir /srv WORKDIR /srv From 3b54867b02f2b1937e0bda27a3383fd3dc7c8267 Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 18 Jun 2024 20:39:07 +0000 Subject: [PATCH 03/15] deployment files --- config.yml | 148 ++++++++++++++++++++++++++ deployment.yaml | 226 ++++++++++++++++++++++++++++++++++++++++ staging/deployment.yaml | 224 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 598 insertions(+) create mode 100644 config.yml create mode 100644 deployment.yaml create mode 100644 staging/deployment.yaml diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..61e531c --- /dev/null +++ b/config.yml @@ -0,0 +1,148 @@ +version: 2.1 +commands: + build_and_deploy: + steps: + - checkout + - setup_remote_docker: + docker_layer_caching: true + - run: + name: install and login doctl + command: | + sudo apt-get update + sudo apt install -y gettext-base openssl + wget https://github.com/digitalocean/doctl/releases/download/v1.45.1/doctl-1.45.1-linux-amd64.tar.gz + tar xf doctl-1.45.1-linux-amd64.tar.gz + sudo mv doctl /usr/local/bin + doctl registry login + - run: + name: install kubectl + command: | + curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl + chmod +x ./kubectl + sudo mv ./kubectl /usr/local/bin/kubectl + sudo apt-get update + sudo apt-get install apt-transport-https ca-certificates gnupg curl + curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg + echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list + sudo apt-get update && sudo apt-get install google-cloud-cli && sudo apt-get install google-cloud-cli-gke-gcloud-auth-plugin -y + echo $GOOGLE_CREDENTIALS > ${HOME}/gcloud-service-key.json + gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json + + - run: + name: configure credentials + command: | + if [ "$CIRCLE_BRANCH" == "dev-rke" ] || [ "$CIRCLE_BRANCH" == "development" ]; then + mkdir ~/.kube + touch ~/.kube/config + cat \< ~/.kube/config + apiVersion: v1 + clusters: + - cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJlRENDQVIrZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWtNU0l3SUFZRFZRUUREQmx5YTJVeUxYTmwKY25abGNpMWpZVUF4TnpBME1EWTJOekV5TUI0WERUSXpNVEl6TVRJek5URTFNbG9YRFRNek1USXlPREl6TlRFMQpNbG93SkRFaU1DQUdBMVVFQXd3WmNtdGxNaTF6WlhKMlpYSXRZMkZBTVRjd05EQTJOamN4TWpCWk1CTUdCeXFHClNNNDlBZ0VHQ0NxR1NNNDlBd0VIQTBJQUJEdzZ1d0xxU3pQWjNUWU1CYURrMmppZklXbmVkQlBGQnZIOG8vVnoKYkdvQUJ4bUFkcTF2Z2dmODN2YWxIVU91QmpWZm1ZQkJsb1lrM1k1bFZHZ3hGeDZqUWpCQU1BNEdBMVVkRHdFQgovd1FFQXdJQ3BEQVBCZ05WSFJNQkFmOEVCVEFEQVFIL01CMEdBMVVkRGdRV0JCU21ScVRzU3hKYlNKU3ZNaGEvCnc2VzVPOHFjMkRBS0JnZ3Foa2pPUFFRREFnTkhBREJFQWlCclZwQXRoZmNreHlvZnc1b3FKcWtmSVliRUc3ajkKNmMrQ05hWlE1NVNBNUFJZ1l1QWs4NjQyK0hrb2dLODljYk1aMHRVVEpRZ1BKZjBVMUVoZzFRVGZsVWs9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K + server: https://rke-k8s.blackdice.ai:6443 + name: default + contexts: + - context: + cluster: default + user: default + name: default + current-context: default + kind: Config + preferences: {} + users: + - name: default + user: + client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJrakNDQVRpZ0F3SUJBZ0lJWTJBQVVxbUFIZTB3Q2dZSUtvWkl6ajBFQXdJd0pERWlNQ0FHQTFVRUF3d1oKY210bE1pMWpiR2xsYm5RdFkyRkFNVGN3TkRBMk5qY3hNakFlRncweU16RXlNekV5TXpVeE5USmFGdzB5TkRFeQpNekF5TXpVeE5USmFNREF4RnpBVkJnTlZCQW9URG5ONWMzUmxiVHB0WVhOMFpYSnpNUlV3RXdZRFZRUURFd3h6CmVYTjBaVzA2WVdSdGFXNHdXVEFUQmdjcWhrak9QUUlCQmdncWhrak9QUU1CQndOQ0FBUXVJTVJWc0NGeURXN0sKVm1JY0tZRFhwOXRLNmJpaE16MU42RStOZXB5VStQRDdzbjE4RUFVQ0lMVW44V09VTUc3WHYzUXV5REhGcE9PMAoydG5rV0lyUG8wZ3dSakFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3dZQkJRVUhBd0l3Ckh3WURWUjBqQkJnd0ZvQVUxOEM3RUxzU1NKa1dsaWJyRGVNNkZ3R09CbDh3Q2dZSUtvWkl6ajBFQXdJRFNBQXcKUlFJZ0RQQUY4QkwzSGk5QitCSTJvTTRId2h6TnpJZ0JMbmd3Z2swa25GWExNdUVDSVFEdTAxVS8rcnlRbTFTSApZaTUrTVhqV25Tb040QjY0VE9xdGNVYkZEaVhOTVE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tQkVHSU4gQ0VSVElGSUNBVEUtLS0tLQpNSUlCZVRDQ0FSK2dBd0lCQWdJQkFEQUtCZ2dxaGtqT1BRUURBakFrTVNJd0lBWURWUVFEREJseWEyVXlMV05zCmFXVnVkQzFqWVVBeE56QTBNRFkyTnpFeU1CNFhEVEl6TVRJek1USXpOVEUxTWxvWERUTXpNVEl5T0RJek5URTEKTWxvd0pERWlNQ0FHQTFVRUF3d1pjbXRsTWkxamJHbGxiblF0WTJGQU1UY3dOREEyTmpjeE1qQlpNQk1HQnlxRwpTTTQ5QWdFR0NDcUdTTTQ5QXdFSEEwSUFCTlFjVS9IdG1admw0eWkwWDB2WDljbXN6YmNZRVZGWkRmWiszdHBYCmR6Ky9tSTJsVmtYaVlHZDF1WlNXTy9pbXVzOFhnaHl3STR1cmR0L0xWNE03S3kyalFqQkFNQTRHQTFVZER3RUIKL3dRRUF3SUNwREFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlRYd0xzUXV4SkltUmFXSnVzTgo0em9YQVk0R1h6QUtCZ2dxaGtqT1BRUURBZ05JQURCRkFpRUE5LzJBNTZ1UXlpMGhxUFNMV0VseEFzV0srRTl5CjZTckJIUm1IS2JLeERDVUNJQlRzZ1U1VHp0K1pmTDlkbkt5K2YrVU4vRVlsczFmakd1ckpPV1ZIbVYwbwotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== + client-key-data: LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSU9kK1FNZDN3elQzMEJ4UHEyUmlCUzU2Z1N6ZG9NeGhUUXk3YTJMNzB1RTZvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFTGlERVZiQWhjZzF1eWxaaUhDbUExNmZiU3VtNG9UTTlUZWhQalhxY2xQancrN0o5ZkJBRgpBaUMxSi9GamxEQnUxNzkwTHNneHhhVGp0TnJaNUZpS3p3PT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo= + EOF + elif [ "$CIRCLE_BRANCH" == "qa" ] || [ "$CIRCLE_BRANCH" == "qa-rke" ]; then + mkdir ~/.kube + touch ~/.kube/config + cat \< ~/.kube/config + apiVersion: v1 + clusters: + - cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJlVENDQVIrZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWtNU0l3SUFZRFZRUUREQmx5YTJVeUxYTmwKY25abGNpMWpZVUF4TnpFd01qYzJOalE0TUI0WERUSTBNRE14TWpJd05UQTBPRm9YRFRNME1ETXhNREl3TlRBMApPRm93SkRFaU1DQUdBMVVFQXd3WmNtdGxNaTF6WlhKMlpYSXRZMkZBTVRjeE1ESTNOalkwT0RCWk1CTUdCeXFHClNNNDlBZ0VHQ0NxR1NNNDlBd0VIQTBJQUJBNHZXRGh3WEhzZm9ESWtWS1l0S2xBL1hleTl1TERPaDkrd1FGbGgKYllQWmVpRjd0WTZMVlBFQWQvUXhvbG5CT05EWWZlR3hRQitWYUx3d3RGOUxVMWFqUWpCQU1BNEdBMVVkRHdFQgovd1FFQXdJQ3BEQVBCZ05WSFJNQkFmOEVCVEFEQVFIL01CMEdBMVVkRGdRV0JCUnZzd3N4RjNvNjJyVnRsZWNzCndWTFZiMkxROURBS0JnZ3Foa2pPUFFRREFnTklBREJGQWlCcndxcVY4amhrVFlvTTByWHZpZGtweWREODRYaEYKQkkzV1VFUFh3cGRtcWdJaEFNOEV3bkNnNTdFUm1zRzhWYzdRckw2OTk2MHJORlovUGF2RXpZTmNlOWdLCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K + server: https://rke-qa.blackdice.ai:6443 + name: default + contexts: + - context: + cluster: default + user: default + name: default + current-context: default + kind: Config + preferences: {} + users: + - name: default + user: + client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJrekNDQVRpZ0F3SUJBZ0lJTE00cTcvSElMRmN3Q2dZSUtvWkl6ajBFQXdJd0pERWlNQ0FHQTFVRUF3d1oKY210bE1pMWpiR2xsYm5RdFkyRkFNVGN4TURJM05qWTBPREFlRncweU5EQXpNVEl5TURVd05EaGFGdzB5TlRBegpNVE14TXpNeU1qTmFNREF4RnpBVkJnTlZCQW9URG5ONWMzUmxiVHB0WVhOMFpYSnpNUlV3RXdZRFZRUURFd3h6CmVYTjBaVzA2WVdSdGFXNHdXVEFUQmdjcWhrak9QUUlCQmdncWhrak9QUU1CQndOQ0FBU1VQWVBBdVhUT29wOUkKclM3VGExYmN0ZXVMTVhmdDJOWlJjVDBma2wzRGxjVzdpMFl0UE9LNWh3Vm56QjRTZmVjcHlSVFZON05UQkZPRgpNRWF5RHZENm8wZ3dSakFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3dZQkJRVUhBd0l3Ckh3WURWUjBqQkJnd0ZvQVVTcDVWeExjUkMrRUlCcG1XWEFtTnhWanphYVl3Q2dZSUtvWkl6ajBFQXdJRFNRQXcKUmdJaEFMakp0YjdBb0xsaFByL1ZHL0ZFdlhCYjlKSkpKUzd0RFFkc1FjTjJrbHIzQWlFQXlXUmdPWGtWZjRKOQpmeDd5TlA4dHg1a05XQWdsakxLNHEyUEZ0bzh1b3ZvPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tQkVHSU4gQ0VSVElGSUNBVEUtLS0tLQpNSUlCZURDQ0FSK2dBd0lCQWdJQkFEQUtCZ2dxaGtqT1BRUURBakFrTVNJd0lBWURWUVFEREJseWEyVXlMV05zCmFXVnVkQzFqWVVBeE56RXdNamMyTmpRNE1CNFhEVEkwTURNeE1qSXdOVEEwT0ZvWERUTTBNRE14TURJd05UQTAKT0Zvd0pERWlNQ0FHQTFVRUF3d1pjbXRsTWkxamJHbGxiblF0WTJGQU1UY3hNREkzTmpZME9EQlpNQk1HQnlxRwpTTTQ5QWdFR0NDcUdTTTQ5QXdFSEEwSUFCRG5IckZiMjVNK3RsZzlOdTFFd0FCSE5hcVdyZGtucW45bGpkSHJOCkFnQyt4Z3FOblVWeU16THM3UEQzZ0svYlp3R0FmYWZZTVlCaE9iR2o3dXFOMXEralFqQkFNQTRHQTFVZER3RUIKL3dRRUF3SUNwREFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlJLbmxYRXR4RUw0UWdHbVpaYwpDWTNGV1BOcHBqQUtCZ2dxaGtqT1BRUURBZ05IQURCRUFpQXBRMm02UDkwc1pDYzZRKzNGUFJWV3hUL1JVeGxaCk53YndlaEdGVnJBa3pRSWdkc0JKWVpwazh1WGtEVFRDNkZ4WGlxWjBObjU4akNYUThnN2lhNkxRZHhnPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== + client-key-data: LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUpjSnF4bFYxeElLNmgrczVuTURZWkQrTW9xbENoUGx4S1YxTXJKODlGaXNvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFbEQyRHdMbDB6cUtmU0swdTAydFczTFhyaXpGMzdkaldVWEU5SDVKZHc1WEZ1NHRHTFR6aQp1WWNGWjh3ZUVuM25LY2tVMVRlelV3UlRoVEJHc2c3dytnPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo= + EOF + elif [ "$CIRCLE_BRANCH" == "staging" ]; then + export CLUSTER=$STAG_CLUSTER + doctl kubernetes cluster kubeconfig save $CLUSTER + elif [ "$CIRCLE_BRANCH" == "gke-staging" ] || [ "$CIRCLE_BRANCH" == "orion" ] || [ "$CIRCLE_BRANCH" == "landatel" ]; then + gcloud container clusters get-credentials blackdice-stag --region europe-central2 --project gke-blackdice + elif [ "$CIRCLE_BRANCH" == "gke-pov" ]; then + gcloud container clusters get-credentials blackdice-pov --region europe-central2 --project gke-blackdice + elif [ "$CIRCLE_BRANCH" == "production" ]; then + gcloud container clusters get-credentials blackdice-prod --region europe-central2 --project gke-blackdice + elif [ -n "${CIRCLE_TAG}" ]; then + gcloud container clusters get-credentials blackdice-prod --region europe-central2 --project gke-blackdice + fi + - run: + name: build and deploy to cluster + command: | + if [ -n "${CIRCLE_TAG}" ]; then + docker build -t $DO_CONTAINER_REGISTRY/$CIRCLE_PROJECT_REPONAME:${CIRCLE_TAG} . + docker push $DO_CONTAINER_REGISTRY/$CIRCLE_PROJECT_REPONAME:${CIRCLE_TAG} + export IMAGE_NAME=$DO_CONTAINER_REGISTRY/$CIRCLE_PROJECT_REPONAME:${CIRCLE_TAG} + else + TAG=`echo $CIRCLE_SHA1 | cut -c1-8` + docker build -t $DO_CONTAINER_REGISTRY/$CIRCLE_PROJECT_REPONAME:$TAG . + docker push $DO_CONTAINER_REGISTRY/$CIRCLE_PROJECT_REPONAME:$TAG + export IMAGE_NAME=$DO_CONTAINER_REGISTRY/$CIRCLE_PROJECT_REPONAME:$TAG + fi + + #Deploy to K8s + export DEPLOYMENT_NAME=netstar-categorizer + + if [ "$CIRCLE_BRANCH" == "staging" ]; then + cat deployment/staging/deployment.yaml | envsubst | kubectl apply -f - + else + cat deployment/deployment.yaml | envsubst | kubectl apply -f - + fi + + +jobs: + build_and_deploy: + docker: + - image: cimg/base:2024.02 + steps: + - build_and_deploy + +workflows: + version: 2 + build-deploy-dev: + jobs: + - build_and_deploy: + filters: + branches: + only: + - dev-rke + - development + - qa + - staging + - production + - dev-rke + - gke-staging + - gke-pov + circleci-serviceplatform-tags: + jobs: + - build_and_deploy: + filters: + tags: + only: /.*/ + branches: + ignore: /.*/ diff --git a/deployment.yaml b/deployment.yaml new file mode 100644 index 0000000..d4d78f4 --- /dev/null +++ b/deployment.yaml @@ -0,0 +1,226 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: $DEPLOYMENT_NAME + name: $DEPLOYMENT_NAME + namespace: blackdice +spec: + replicas: 1 + selector: + matchLabels: + app: $DEPLOYMENT_NAME + template: + metadata: + labels: + app: $DEPLOYMENT_NAME + spec: + imagePullSecrets: + - name: do-registry + containers: + - env: + - name: NODE_ENV + valueFrom: + secretKeyRef: + key: NODE_ENV + name: serviceplatform-env + - name: MYSQL_URL + valueFrom: + secretKeyRef: + key: MYSQL_URL + name: serviceplatform-env + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + key: MYSQL_PASSWORD + name: serviceplatform-env + - name: MYSQL_PORT + valueFrom: + secretKeyRef: + key: MYSQL_PORT + name: serviceplatform-env + - name: MYSQL_DATABASE + valueFrom: + secretKeyRef: + key: MYSQL_DATABASE + name: serviceplatform-env + - name: MYSQL_USER + valueFrom: + secretKeyRef: + key: MYSQL_USER + name: serviceplatform-env + - name: DB_DIALECT + valueFrom: + secretKeyRef: + key: DB_DIALECT + name: serviceplatform-env + - name: REDIS_URL + valueFrom: + secretKeyRef: + key: REDIS_URL + name: serviceplatform-env + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + key: REDIS_PASSWORD + name: serviceplatform-env + - name: REDIS_PORT + valueFrom: + secretKeyRef: + key: REDIS_PORT + name: serviceplatform-env + - name: COMMUNICATOR_ADDRESS + valueFrom: + secretKeyRef: + key: COMMUNICATOR_ADDRESS + name: serviceplatform-env + - name: SIGNING_KEY + valueFrom: + secretKeyRef: + key: SIGNING_KEY + name: serviceplatform-env + - name: MQTT_HOST + valueFrom: + secretKeyRef: + key: MQTT_HOST + name: serviceplatform-env + - name: MQTT_USERNAME + valueFrom: + secretKeyRef: + key: MQTT_USERNAME + name: serviceplatform-env + - name: MQTT_PASSWORD + valueFrom: + secretKeyRef: + key: MQTT_PASSWORD + name: serviceplatform-env + - name: FIREBASE_ENV + valueFrom: + secretKeyRef: + key: FIREBASE_ENV + name: serviceplatform-env + - name: APNS_TOPIC + valueFrom: + secretKeyRef: + key: APNS_TOPIC + name: serviceplatform-env + - name: MDM_API_TOKEN + valueFrom: + secretKeyRef: + key: MDM_API_TOKEN + name: serviceplatform-env + - name: MDM_AUTH + valueFrom: + secretKeyRef: + key: MDM_AUTH + name: serviceplatform-env + - name: MDM_SERVICE_URL + valueFrom: + secretKeyRef: + key: MDM_SERVICE_URL + name: serviceplatform-env + - name: DNS_URL + valueFrom: + secretKeyRef: + key: DNS_URL + name: serviceplatform-env + - name: MYSQL_DATABASE_THREAT + valueFrom: + secretKeyRef: + key: MYSQL_DATABASE_THREAT + name: serviceplatform-env + - name: MONGO_COLLECTION + valueFrom: + secretKeyRef: + key: MONGO_COLLECTION + name: serviceplatform-env + - name: MONGO_URI + valueFrom: + secretKeyRef: + key: MONGO_URI + name: serviceplatform-env + - name: MONGO_DATABASE + valueFrom: + secretKeyRef: + key: MONGO_DATABASE + name: serviceplatform-env + - name: RETINA_EMAIL_REDIRECT + valueFrom: + secretKeyRef: + key: RETINA_EMAIL_REDIRECT + name: serviceplatform-env + - name: CORS_ORIGINS + valueFrom: + secretKeyRef: + key: CORS_ORIGINS + name: serviceplatform-env + - name: AMA_OAUTH_SCOPE + valueFrom: + secretKeyRef: + key: AMA_OAUTH_SCOPE + name: serviceplatform-env + - name: AMA_PROJECT_ID + valueFrom: + secretKeyRef: + key: AMA_PROJECT_ID + name: serviceplatform-env + - name: AMA_PRIVATE_KEY + valueFrom: + secretKeyRef: + key: AMA_PRIVATE_KEY + name: serviceplatform-env + - name: AMA_SERVICE_EMAIL + valueFrom: + secretKeyRef: + key: AMA_SERVICE_EMAIL + name: serviceplatform-env + - name: AMA_SUBSCRIPTION_NAME + valueFrom: + secretKeyRef: + key: AMA_SUBSCRIPTION_NAME + name: serviceplatform-env + - name: AMA_PS_SERVICE_EMAIL + valueFrom: + secretKeyRef: + key: AMA_PS_SERVICE_EMAIL + name: serviceplatform-env + - name: AMA_PS_PRIVATE_KEY + valueFrom: + secretKeyRef: + key: AMA_PS_PRIVATE_KEY + name: serviceplatform-env + - name: AGENT_STORAGE + valueFrom: + secretKeyRef: + key: AGENT_STORAGE + name: serviceplatform-env + - name: AGENT_STORAGE_KEY + valueFrom: + secretKeyRef: + key: AGENT_STORAGE_KEY + name: serviceplatform-env + image: $IMAGE_NAME + imagePullPolicy: Always + name: $DEPLOYMENT_NAME + ports: + - containerPort: 3000 + protocol: TCP + restartPolicy: Always + + +--- +apiVersion: v1 +kind: Service +metadata: + name: $DEPLOYMENT_NAME + namespace: blackdice +spec: + ports: + - name: $DEPLOYMENT_NAME + port: 3000 + protocol: TCP + targetPort: 3000 + selector: + app: $DEPLOYMENT_NAME + type: ClusterIP diff --git a/staging/deployment.yaml b/staging/deployment.yaml new file mode 100644 index 0000000..dc6be67 --- /dev/null +++ b/staging/deployment.yaml @@ -0,0 +1,224 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: $DEPLOYMENT_NAME + name: $DEPLOYMENT_NAME + namespace: blackdice +spec: + replicas: 1 + selector: + matchLabels: + app: $DEPLOYMENT_NAME + template: + metadata: + labels: + app: $DEPLOYMENT_NAME + spec: + containers: + - env: + - name: NODE_ENV + valueFrom: + secretKeyRef: + key: NODE_ENV + name: serviceplatform-env + - name: MYSQL_URL + valueFrom: + secretKeyRef: + key: MYSQL_URL + name: serviceplatform-env + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + key: MYSQL_PASSWORD + name: serviceplatform-env + - name: MYSQL_PORT + valueFrom: + secretKeyRef: + key: MYSQL_PORT + name: serviceplatform-env + - name: MYSQL_DATABASE + valueFrom: + secretKeyRef: + key: MYSQL_DATABASE + name: serviceplatform-env + - name: MYSQL_USER + valueFrom: + secretKeyRef: + key: MYSQL_USER + name: serviceplatform-env + - name: DB_DIALECT + valueFrom: + secretKeyRef: + key: DB_DIALECT + name: serviceplatform-env + - name: REDIS_URL + valueFrom: + secretKeyRef: + key: REDIS_URL + name: serviceplatform-env + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + key: REDIS_PASSWORD + name: serviceplatform-env + - name: REDIS_PORT + valueFrom: + secretKeyRef: + key: REDIS_PORT + name: serviceplatform-env + - name: COMMUNICATOR_ADDRESS + valueFrom: + secretKeyRef: + key: COMMUNICATOR_ADDRESS + name: serviceplatform-env + - name: SIGNING_KEY + valueFrom: + secretKeyRef: + key: SIGNING_KEY + name: serviceplatform-env + - name: MQTT_HOST + valueFrom: + secretKeyRef: + key: MQTT_HOST + name: serviceplatform-env + - name: MQTT_USERNAME + valueFrom: + secretKeyRef: + key: MQTT_USERNAME + name: serviceplatform-env + - name: MQTT_PASSWORD + valueFrom: + secretKeyRef: + key: MQTT_PASSWORD + name: serviceplatform-env + - name: FIREBASE_ENV + valueFrom: + secretKeyRef: + key: FIREBASE_ENV + name: serviceplatform-env + - name: APNS_TOPIC + valueFrom: + secretKeyRef: + key: APNS_TOPIC + name: serviceplatform-env + - name: MDM_API_TOKEN + valueFrom: + secretKeyRef: + key: MDM_API_TOKEN + name: serviceplatform-env + - name: MDM_AUTH + valueFrom: + secretKeyRef: + key: MDM_AUTH + name: serviceplatform-env + - name: MDM_SERVICE_URL + valueFrom: + secretKeyRef: + key: MDM_SERVICE_URL + name: serviceplatform-env + - name: DNS_URL + valueFrom: + secretKeyRef: + key: DNS_URL + name: serviceplatform-env + - name: MYSQL_DATABASE_THREAT + valueFrom: + secretKeyRef: + key: MYSQL_DATABASE_THREAT + name: serviceplatform-env + - name: MONGO_COLLECTION + valueFrom: + secretKeyRef: + key: MONGO_COLLECTION + name: serviceplatform-env + - name: MONGO_URI + valueFrom: + secretKeyRef: + key: MONGO_URI + name: serviceplatform-env + - name: MONGO_DATABASE + valueFrom: + secretKeyRef: + key: MONGO_DATABASE + name: serviceplatform-env + - name: RETINA_EMAIL_REDIRECT + valueFrom: + secretKeyRef: + key: RETINA_EMAIL_REDIRECT + name: serviceplatform-env + - name: CORS_ORIGINS + valueFrom: + secretKeyRef: + key: CORS_ORIGINS + name: serviceplatform-env + - name: AMA_OAUTH_SCOPE + valueFrom: + secretKeyRef: + key: AMA_OAUTH_SCOPE + name: serviceplatform-env + - name: AMA_PROJECT_ID + valueFrom: + secretKeyRef: + key: AMA_PROJECT_ID + name: serviceplatform-env + - name: AMA_PRIVATE_KEY + valueFrom: + secretKeyRef: + key: AMA_PRIVATE_KEY + name: serviceplatform-env + - name: AMA_SERVICE_EMAIL + valueFrom: + secretKeyRef: + key: AMA_SERVICE_EMAIL + name: serviceplatform-env + - name: AMA_SUBSCRIPTION_NAME + valueFrom: + secretKeyRef: + key: AMA_SUBSCRIPTION_NAME + name: serviceplatform-env + - name: AMA_PS_SERVICE_EMAIL + valueFrom: + secretKeyRef: + key: AMA_PS_SERVICE_EMAIL + name: serviceplatform-env + - name: AMA_PS_PRIVATE_KEY + valueFrom: + secretKeyRef: + key: AMA_PS_PRIVATE_KEY + name: serviceplatform-env + - name: AGENT_STORAGE + valueFrom: + secretKeyRef: + key: AGENT_STORAGE + name: serviceplatform-env + - name: AGENT_STORAGE_KEY + valueFrom: + secretKeyRef: + key: AGENT_STORAGE_KEY + name: serviceplatform-env + image: $IMAGE_NAME + imagePullPolicy: Always + name: $DEPLOYMENT_NAME + ports: + - containerPort: 3000 + protocol: TCP + restartPolicy: Always + + +--- +apiVersion: v1 +kind: Service +metadata: + name: $DEPLOYMENT_NAME + namespace: blackdice +spec: + ports: + - name: $DEPLOYMENT_NAME + port: 3000 + protocol: TCP + targetPort: 3000 + selector: + app: $DEPLOYMENT_NAME + type: ClusterIP From f64bb82960cdc6682362829ef1e3eb14369508f7 Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 18 Jun 2024 20:46:48 +0000 Subject: [PATCH 04/15] deployment files --- config.yml => .circleci/config.yml | 0 deployment.yaml | 226 ----------------------------- deployment/deployment.yaml | 45 ++++++ deployment/staging/deployment.yaml | 43 ++++++ 4 files changed, 88 insertions(+), 226 deletions(-) rename config.yml => .circleci/config.yml (100%) delete mode 100644 deployment.yaml create mode 100644 deployment/deployment.yaml create mode 100644 deployment/staging/deployment.yaml diff --git a/config.yml b/.circleci/config.yml similarity index 100% rename from config.yml rename to .circleci/config.yml diff --git a/deployment.yaml b/deployment.yaml deleted file mode 100644 index d4d78f4..0000000 --- a/deployment.yaml +++ /dev/null @@ -1,226 +0,0 @@ ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: $DEPLOYMENT_NAME - name: $DEPLOYMENT_NAME - namespace: blackdice -spec: - replicas: 1 - selector: - matchLabels: - app: $DEPLOYMENT_NAME - template: - metadata: - labels: - app: $DEPLOYMENT_NAME - spec: - imagePullSecrets: - - name: do-registry - containers: - - env: - - name: NODE_ENV - valueFrom: - secretKeyRef: - key: NODE_ENV - name: serviceplatform-env - - name: MYSQL_URL - valueFrom: - secretKeyRef: - key: MYSQL_URL - name: serviceplatform-env - - name: MYSQL_PASSWORD - valueFrom: - secretKeyRef: - key: MYSQL_PASSWORD - name: serviceplatform-env - - name: MYSQL_PORT - valueFrom: - secretKeyRef: - key: MYSQL_PORT - name: serviceplatform-env - - name: MYSQL_DATABASE - valueFrom: - secretKeyRef: - key: MYSQL_DATABASE - name: serviceplatform-env - - name: MYSQL_USER - valueFrom: - secretKeyRef: - key: MYSQL_USER - name: serviceplatform-env - - name: DB_DIALECT - valueFrom: - secretKeyRef: - key: DB_DIALECT - name: serviceplatform-env - - name: REDIS_URL - valueFrom: - secretKeyRef: - key: REDIS_URL - name: serviceplatform-env - - name: REDIS_PASSWORD - valueFrom: - secretKeyRef: - key: REDIS_PASSWORD - name: serviceplatform-env - - name: REDIS_PORT - valueFrom: - secretKeyRef: - key: REDIS_PORT - name: serviceplatform-env - - name: COMMUNICATOR_ADDRESS - valueFrom: - secretKeyRef: - key: COMMUNICATOR_ADDRESS - name: serviceplatform-env - - name: SIGNING_KEY - valueFrom: - secretKeyRef: - key: SIGNING_KEY - name: serviceplatform-env - - name: MQTT_HOST - valueFrom: - secretKeyRef: - key: MQTT_HOST - name: serviceplatform-env - - name: MQTT_USERNAME - valueFrom: - secretKeyRef: - key: MQTT_USERNAME - name: serviceplatform-env - - name: MQTT_PASSWORD - valueFrom: - secretKeyRef: - key: MQTT_PASSWORD - name: serviceplatform-env - - name: FIREBASE_ENV - valueFrom: - secretKeyRef: - key: FIREBASE_ENV - name: serviceplatform-env - - name: APNS_TOPIC - valueFrom: - secretKeyRef: - key: APNS_TOPIC - name: serviceplatform-env - - name: MDM_API_TOKEN - valueFrom: - secretKeyRef: - key: MDM_API_TOKEN - name: serviceplatform-env - - name: MDM_AUTH - valueFrom: - secretKeyRef: - key: MDM_AUTH - name: serviceplatform-env - - name: MDM_SERVICE_URL - valueFrom: - secretKeyRef: - key: MDM_SERVICE_URL - name: serviceplatform-env - - name: DNS_URL - valueFrom: - secretKeyRef: - key: DNS_URL - name: serviceplatform-env - - name: MYSQL_DATABASE_THREAT - valueFrom: - secretKeyRef: - key: MYSQL_DATABASE_THREAT - name: serviceplatform-env - - name: MONGO_COLLECTION - valueFrom: - secretKeyRef: - key: MONGO_COLLECTION - name: serviceplatform-env - - name: MONGO_URI - valueFrom: - secretKeyRef: - key: MONGO_URI - name: serviceplatform-env - - name: MONGO_DATABASE - valueFrom: - secretKeyRef: - key: MONGO_DATABASE - name: serviceplatform-env - - name: RETINA_EMAIL_REDIRECT - valueFrom: - secretKeyRef: - key: RETINA_EMAIL_REDIRECT - name: serviceplatform-env - - name: CORS_ORIGINS - valueFrom: - secretKeyRef: - key: CORS_ORIGINS - name: serviceplatform-env - - name: AMA_OAUTH_SCOPE - valueFrom: - secretKeyRef: - key: AMA_OAUTH_SCOPE - name: serviceplatform-env - - name: AMA_PROJECT_ID - valueFrom: - secretKeyRef: - key: AMA_PROJECT_ID - name: serviceplatform-env - - name: AMA_PRIVATE_KEY - valueFrom: - secretKeyRef: - key: AMA_PRIVATE_KEY - name: serviceplatform-env - - name: AMA_SERVICE_EMAIL - valueFrom: - secretKeyRef: - key: AMA_SERVICE_EMAIL - name: serviceplatform-env - - name: AMA_SUBSCRIPTION_NAME - valueFrom: - secretKeyRef: - key: AMA_SUBSCRIPTION_NAME - name: serviceplatform-env - - name: AMA_PS_SERVICE_EMAIL - valueFrom: - secretKeyRef: - key: AMA_PS_SERVICE_EMAIL - name: serviceplatform-env - - name: AMA_PS_PRIVATE_KEY - valueFrom: - secretKeyRef: - key: AMA_PS_PRIVATE_KEY - name: serviceplatform-env - - name: AGENT_STORAGE - valueFrom: - secretKeyRef: - key: AGENT_STORAGE - name: serviceplatform-env - - name: AGENT_STORAGE_KEY - valueFrom: - secretKeyRef: - key: AGENT_STORAGE_KEY - name: serviceplatform-env - image: $IMAGE_NAME - imagePullPolicy: Always - name: $DEPLOYMENT_NAME - ports: - - containerPort: 3000 - protocol: TCP - restartPolicy: Always - - ---- -apiVersion: v1 -kind: Service -metadata: - name: $DEPLOYMENT_NAME - namespace: blackdice -spec: - ports: - - name: $DEPLOYMENT_NAME - port: 3000 - protocol: TCP - targetPort: 3000 - selector: - app: $DEPLOYMENT_NAME - type: ClusterIP diff --git a/deployment/deployment.yaml b/deployment/deployment.yaml new file mode 100644 index 0000000..f91c0a3 --- /dev/null +++ b/deployment/deployment.yaml @@ -0,0 +1,45 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: $DEPLOYMENT_NAME + name: $DEPLOYMENT_NAME + namespace: blackdice +spec: + replicas: 1 + selector: + matchLabels: + app: $DEPLOYMENT_NAME + template: + metadata: + labels: + app: $DEPLOYMENT_NAME + spec: + imagePullSecrets: + - name: do-registry + containers: + image: $IMAGE_NAME + imagePullPolicy: Always + name: $DEPLOYMENT_NAME + ports: + - containerPort: 3000 + protocol: TCP + restartPolicy: Always + + +--- +apiVersion: v1 +kind: Service +metadata: + name: $DEPLOYMENT_NAME + namespace: blackdice +spec: + ports: + - name: $DEPLOYMENT_NAME + port: 3000 + protocol: TCP + targetPort: 3000 + selector: + app: $DEPLOYMENT_NAME + type: ClusterIP diff --git a/deployment/staging/deployment.yaml b/deployment/staging/deployment.yaml new file mode 100644 index 0000000..9ac30c3 --- /dev/null +++ b/deployment/staging/deployment.yaml @@ -0,0 +1,43 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: $DEPLOYMENT_NAME + name: $DEPLOYMENT_NAME + namespace: blackdice +spec: + replicas: 1 + selector: + matchLabels: + app: $DEPLOYMENT_NAME + template: + metadata: + labels: + app: $DEPLOYMENT_NAME + spec: + containers: + image: $IMAGE_NAME + imagePullPolicy: Always + name: $DEPLOYMENT_NAME + ports: + - containerPort: 3000 + protocol: TCP + restartPolicy: Always + + +--- +apiVersion: v1 +kind: Service +metadata: + name: $DEPLOYMENT_NAME + namespace: blackdice +spec: + ports: + - name: $DEPLOYMENT_NAME + port: 3000 + protocol: TCP + targetPort: 3000 + selector: + app: $DEPLOYMENT_NAME + type: ClusterIP From f0e8b16c9d6cfb528c62446801703c71ded28ca9 Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 18 Jun 2024 20:48:08 +0000 Subject: [PATCH 05/15] deployment files --- deployment/deployment.yaml | 2 +- deployment/staging/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/deployment.yaml b/deployment/deployment.yaml index f91c0a3..ef87ff5 100644 --- a/deployment/deployment.yaml +++ b/deployment/deployment.yaml @@ -19,7 +19,7 @@ spec: imagePullSecrets: - name: do-registry containers: - image: $IMAGE_NAME + - image: $IMAGE_NAME imagePullPolicy: Always name: $DEPLOYMENT_NAME ports: diff --git a/deployment/staging/deployment.yaml b/deployment/staging/deployment.yaml index 9ac30c3..b726ccb 100644 --- a/deployment/staging/deployment.yaml +++ b/deployment/staging/deployment.yaml @@ -17,7 +17,7 @@ spec: app: $DEPLOYMENT_NAME spec: containers: - image: $IMAGE_NAME + - image: $IMAGE_NAME imagePullPolicy: Always name: $DEPLOYMENT_NAME ports: From 2a0cad4779e028b5021a83ab6633d430d6af6381 Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 18 Jun 2024 20:49:56 +0000 Subject: [PATCH 06/15] deployment files --- deployment/staging/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/staging/deployment.yaml b/deployment/staging/deployment.yaml index b726ccb..1400a96 100644 --- a/deployment/staging/deployment.yaml +++ b/deployment/staging/deployment.yaml @@ -40,4 +40,4 @@ spec: targetPort: 3000 selector: app: $DEPLOYMENT_NAME - type: ClusterIP + type: ClusterIP \ No newline at end of file From 7c317678ca9d846449372fe3f486ed8ea604872c Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 18 Jun 2024 20:59:37 +0000 Subject: [PATCH 07/15] deployment files --- deployment/deployment.yaml | 2 +- deployment/staging/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/deployment.yaml b/deployment/deployment.yaml index ef87ff5..b09fa4c 100644 --- a/deployment/deployment.yaml +++ b/deployment/deployment.yaml @@ -24,7 +24,7 @@ spec: name: $DEPLOYMENT_NAME ports: - containerPort: 3000 - protocol: TCP + protocol: UDP restartPolicy: Always diff --git a/deployment/staging/deployment.yaml b/deployment/staging/deployment.yaml index 1400a96..8b6cc86 100644 --- a/deployment/staging/deployment.yaml +++ b/deployment/staging/deployment.yaml @@ -22,7 +22,7 @@ spec: name: $DEPLOYMENT_NAME ports: - containerPort: 3000 - protocol: TCP + protocol: UDP restartPolicy: Always From 7d0ccd1ff1f824a669d9a37beecc1fc88a33cf07 Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 18 Jun 2024 21:06:26 +0000 Subject: [PATCH 08/15] deployment files --- deployment/deployment.yaml | 24 ++++++++++++++++++++++++ deployment/staging/deployment.yaml | 25 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/deployment/deployment.yaml b/deployment/deployment.yaml index b09fa4c..c6016e1 100644 --- a/deployment/deployment.yaml +++ b/deployment/deployment.yaml @@ -43,3 +43,27 @@ spec: selector: app: $DEPLOYMENT_NAME type: ClusterIP + + +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: $DEPLOYMENT_NAME +spec: + schedule: "0 0 * * *" + jobTemplate: + spec: + template: + spec: + containers: + - name: $DEPLOYMENT_NAME + image: $IMAGE_NAME + command: ["/bin/bash", "-c"] + args: [ + "/usr/local/gcf1/bin/gcf1dbmng.sh etc urldb_download && \ + /usr/local/gcf1/bin/gcf1dbmng.sh etc urldb_update" + ] + restartPolicy: OnFailure + backoffLimit: 4 + diff --git a/deployment/staging/deployment.yaml b/deployment/staging/deployment.yaml index 8b6cc86..e3d977d 100644 --- a/deployment/staging/deployment.yaml +++ b/deployment/staging/deployment.yaml @@ -40,4 +40,27 @@ spec: targetPort: 3000 selector: app: $DEPLOYMENT_NAME - type: ClusterIP \ No newline at end of file + type: ClusterIP + + +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: $DEPLOYMENT_NAME +spec: + schedule: "0 0 * * *" + jobTemplate: + spec: + template: + spec: + containers: + - name: $DEPLOYMENT_NAME + image: $IMAGE_NAME + command: ["/bin/bash", "-c"] + args: [ + "/usr/local/gcf1/bin/gcf1dbmng.sh etc urldb_download && \ + /usr/local/gcf1/bin/gcf1dbmng.sh etc urldb_update" + ] + restartPolicy: OnFailure + backoffLimit: 4 \ No newline at end of file From c8caac7da126a1dafa6c8e402afa263e88993b15 Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 18 Jun 2024 21:13:10 +0000 Subject: [PATCH 09/15] deployment files --- deployment/deployment.yaml | 1 + deployment/staging/deployment.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/deployment/deployment.yaml b/deployment/deployment.yaml index c6016e1..92eefbc 100644 --- a/deployment/deployment.yaml +++ b/deployment/deployment.yaml @@ -50,6 +50,7 @@ apiVersion: batch/v1 kind: CronJob metadata: name: $DEPLOYMENT_NAME + namespace: blackdice spec: schedule: "0 0 * * *" jobTemplate: diff --git a/deployment/staging/deployment.yaml b/deployment/staging/deployment.yaml index e3d977d..01acb35 100644 --- a/deployment/staging/deployment.yaml +++ b/deployment/staging/deployment.yaml @@ -48,6 +48,7 @@ apiVersion: batch/v1 kind: CronJob metadata: name: $DEPLOYMENT_NAME + namespace: blackdice spec: schedule: "0 0 * * *" jobTemplate: From 719596451e6e61f4f1c334f2a4a909300d438b88 Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 18 Jun 2024 21:21:11 +0000 Subject: [PATCH 10/15] deployment files --- deployment/deployment.yaml | 2 +- deployment/staging/deployment.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/deployment.yaml b/deployment/deployment.yaml index 92eefbc..c5576d4 100644 --- a/deployment/deployment.yaml +++ b/deployment/deployment.yaml @@ -38,7 +38,7 @@ spec: ports: - name: $DEPLOYMENT_NAME port: 3000 - protocol: TCP + protocol: UDP targetPort: 3000 selector: app: $DEPLOYMENT_NAME diff --git a/deployment/staging/deployment.yaml b/deployment/staging/deployment.yaml index 01acb35..20460a3 100644 --- a/deployment/staging/deployment.yaml +++ b/deployment/staging/deployment.yaml @@ -36,7 +36,7 @@ spec: ports: - name: $DEPLOYMENT_NAME port: 3000 - protocol: TCP + protocol: UDP targetPort: 3000 selector: app: $DEPLOYMENT_NAME From 5c7d12f6d816e68a342927aeaef8376b907a0eb3 Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 9 Jul 2024 08:21:34 +0000 Subject: [PATCH 11/15] modified files --- config.yml | 0 deployment/staging/Untitled-1.md | 21 +++++++++++++++++++++ ingress.yaml | 23 +++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 config.yml create mode 100644 deployment/staging/Untitled-1.md create mode 100644 ingress.yaml diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..e69de29 diff --git a/deployment/staging/Untitled-1.md b/deployment/staging/Untitled-1.md new file mode 100644 index 0000000..ef715b6 --- /dev/null +++ b/deployment/staging/Untitled-1.md @@ -0,0 +1,21 @@ +https://mercku-stag.blackdice.io,https://paltel-stag.blackdice.io,https://retina-stag.blackdice.io,https://retina-stag.blackdice.ai,https://stag.blackdice.io,https://stag.blackdice.ai,https://liteon.blackdice.io,https://mercku.blackdice.io,https://paltel.blackdice.io,http://localhost:3000,https://preprod.blackdice.ai,https://retina-preprod.blackdice.ai,https://landatel-preprod.blackdice.ai,https://orion-preprod.blackdice.ai,https://retina.blackdice.ai,https://app.blackdice.ai,https://landatel.blackdice.ai,https://orion.blackdice.ai,pov.blackdice.ai,retina-pov.blackdice.ai,https://datageneral-preprod.blackdice.ai + + + +hostnames IP Access Type(internal/external) +amlp.aapac.mittalco.com 10.235.32.233 internal +aml-insyt-api.aapac.mittalco.com 10.235.32.233 external +aml-insyt.aapac.mittalco.com 10.235.32.233 external +aml-insyt-sso.aapac.mittalco.com 10.235.32.233 external +aml-accounts.aapac.mittalco.com 10.235.32.233 external +aml-analytics.aapac.mittalco.com 10.235.32.233 external +aml-analytics-api.aapac.mittalco.com 10.235.32.233 external +logsdb.aapac.mittalco.com 10.235.32.237 internal +mongo-aml.aapac.mittalco.com 10.235.32.236 internal +pg-aml.aapac.mittalco.com 10.235.32.238 internal +yek-rdp01-mgr1.aapac.mittalco.com 10.235.32.233 internal +yek-rdp03-webapp01.aapac.mittalco.com 10.235.32.234 internal +yek-rdp04-api01.aapac.mittalco.com 10.235.32.235 internal +yek-rdp04-mongo01.aapac.mittalco.com 10.235.32.236 internal +yek-rdp04-search01.aapac.mittalco.com 10.235.32.237 internal +yek-rdp-postgres01.aapac.mittalco.com 10.235.32.238 internal diff --git a/ingress.yaml b/ingress.yaml new file mode 100644 index 0000000..c3a5a80 --- /dev/null +++ b/ingress.yaml @@ -0,0 +1,23 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + name: netstar-categorizer + namespace: blackdice +spec: + ingressClassName: nginx + rules: + - host: netstar-cat-dev.blackdice.ai + http: + paths: + - backend: + service: + name: netstar-categorizer + port: + number: 3000 + path: / + pathType: ImplementationSpecific + tls: + - hosts: + - dns-dev.blackdice.ai + secretName: blackdice-ai From cec0b650aa318118cf3987d38b3392069f992146 Mon Sep 17 00:00:00 2001 From: eamoany Date: Tue, 9 Jul 2024 08:22:13 +0000 Subject: [PATCH 12/15] modified files --- ingress.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/ingress.yaml b/ingress.yaml index c3a5a80..15a74a6 100644 --- a/ingress.yaml +++ b/ingress.yaml @@ -1,7 +1,6 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - annotations: name: netstar-categorizer namespace: blackdice spec: From 7f59ce78bcb299aec302dfac32228f115fbc9304 Mon Sep 17 00:00:00 2001 From: daniel muniz Date: Mon, 15 Jul 2024 12:25:40 -0300 Subject: [PATCH 13/15] implementing singleton --- src/use-cases/category-converter-use-case.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/use-cases/category-converter-use-case.js b/src/use-cases/category-converter-use-case.js index d55b2b0..8a4d2af 100644 --- a/src/use-cases/category-converter-use-case.js +++ b/src/use-cases/category-converter-use-case.js @@ -1,11 +1,15 @@ - class CategoryConverterUseCase { - constructor({categoriesMapping}) { - this.categoriesMapping = categoriesMapping + constructor({ categoriesMapping }) { + if (CategoryConverterUseCase.instance) { + return CategoryConverterUseCase.instance; + } + + this.categoriesMapping = categoriesMapping; + CategoryConverterUseCase.instance = this; } execute(category) { - const entry = this.categoriesMapping.find(item => item.id === category) + const entry = this.categoriesMapping.find(item => item.id === category); return entry ? entry.related[0].split(', ').map(str => str.trim()) : null; } From 5fbeb896c5ac4f1c10412b1ab788057642148788 Mon Sep 17 00:00:00 2001 From: daniel muniz Date: Wed, 24 Jul 2024 19:42:14 -0300 Subject: [PATCH 14/15] implementing cron --- src/cron.js | 10 ++++++++++ src/server.js | 6 +++++- src/use-cases/update-categories-use-case.js | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/cron.js create mode 100644 src/use-cases/update-categories-use-case.js diff --git a/src/cron.js b/src/cron.js new file mode 100644 index 0000000..ab71740 --- /dev/null +++ b/src/cron.js @@ -0,0 +1,10 @@ +const { UpdateCategoriesUseCase } = require('./use-cases/update-categories-use-case') + +const updateCategories = new UpdateCategoriesUseCase() + +module.exports = async function cron() { + const oneDay = 1000 * 60 * 60 * 24 + setImmediate(() => { + updateCategories.execute() + }, oneDay) +} diff --git a/src/server.js b/src/server.js index f46dec7..99b9e34 100644 --- a/src/server.js +++ b/src/server.js @@ -1,11 +1,15 @@ require('dotenv').config() const dgram = require('dgram'); -const server = dgram.createSocket('udp4'); const app = require('./app') +const cron = require('./cron') + +cron() const PORT = process.env.PORT +const server = dgram.createSocket('udp4'); + server.on('error', (err) => { console.log(`Server error:\n${err.stack}`); server.close(); diff --git a/src/use-cases/update-categories-use-case.js b/src/use-cases/update-categories-use-case.js new file mode 100644 index 0000000..df40dfc --- /dev/null +++ b/src/use-cases/update-categories-use-case.js @@ -0,0 +1,20 @@ +const { exec } = require("node:child_process") + +class UpdateCategoriesUseCase { + execute() { + return new Promise((_, reject) => { + exec(`bin/gcf1dbmng.sh etc urldb_update`, { cwd: '/usr/local/gcf1' }, (error, stdout, stderr) => { + if (error) { + console.error(error); + reject(error); + return; + } + + console.log(stdout) + }); + }); + } +} + +module.exports = { UpdateCategoriesUseCase } + From af8d8bdfc91ec8856137282118b6fefa91fea621 Mon Sep 17 00:00:00 2001 From: daniel muniz Date: Tue, 30 Jul 2024 12:46:58 -0300 Subject: [PATCH 15/15] implementig http approach --- .env.example | 3 +- package-lock.json | 684 +++++++++++++- package.json | 3 +- src/app.js | 4 +- src/etc/categories-mapping.json | 1541 ++++++++++++++++++++++++++++--- src/server.js | 37 +- 6 files changed, 2138 insertions(+), 134 deletions(-) diff --git a/.env.example b/.env.example index 42ccf95..a328da6 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ -PORT=33333 \ No newline at end of file +UDP_PORT=33333 +HTTP_PORT=3333 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7702bba..33c0245 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,147 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "dotenv": "^16.4.5" + "dotenv": "^16.4.5", + "express": "^4.19.2" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, + "node_modules/body-parser": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" } }, "node_modules/dotenv": { @@ -22,6 +162,548 @@ "funding": { "url": "https://dotenvx.com" } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.2", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.6.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-inspect": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", + "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/send": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.18.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "node_modules/side-channel": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", + "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", + "dependencies": { + "call-bind": "^1.0.7", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } } } } diff --git a/package.json b/package.json index 2b89d6a..fe57941 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "license": "ISC", "description": "", "dependencies": { - "dotenv": "^16.4.5" + "dotenv": "^16.4.5", + "express": "^4.19.2" } } diff --git a/src/app.js b/src/app.js index dde5770..fc12cc2 100644 --- a/src/app.js +++ b/src/app.js @@ -8,9 +8,9 @@ const categoryConverter = new CategoryConverterUseCase({categoriesMapping}); module.exports = async function app(domain){ const category = await getCategory.execute(domain) - + console.log(category) const categoryConverted = await categoryConverter.execute(category) - + console.log(categoryConverted) return categoryConverted } diff --git a/src/etc/categories-mapping.json b/src/etc/categories-mapping.json index afc09e6..84b9255 100644 --- a/src/etc/categories-mapping.json +++ b/src/etc/categories-mapping.json @@ -1,176 +1,1465 @@ [ - { - "id": "701", - "related": [ - "10005" - ] - }, - { - "id": "20066", - "related": [ - "10298" - ] - }, - { - "id": "401", - "related": [ - "10076" - ] - }, - { - "id": "402", - "related": [ - "10297, 10300" - ] - }, - { - "id": "20068", - "related": [ - "10297" - ] - }, - { - "id": "20082", - "related": [ - "10080" - ] - }, - { - "id": "204", - "related": [ - "10016, 10018" - ] - }, - { + { "id": "101", + "description": "Illegal Activities", "related": [ - "10084, 10078" + "10075" ] - }, - { - "id": "301", + }, + { + "id": "102", + "description": "Illegal Drugs", "related": [ - "10009, 10008" + "10078" ] - }, - { - "id": "501", + }, + { + "id": "103", + "description": "Medication", "related": [ - "10283" + "10186" ] - }, - { - "id": "305", + }, + { + "id": "104", + "description": "Marijuana", "related": [ - "10074" + "10079" ] - }, - { + }, + { + "id": "105", + "description": "CBD & Hemp Products", + "related": [ + "10079" + ] + }, + { + "id": "201", + "description": "Terrorism/Extremists", + "related": [ + "10018" + ] + }, + { + "id": "202", + "description": "Weapons", + "related": [ + "10017" + ] + }, + { + "id": "203", + "description": "Hate/Slander", + "related": [ + "10077" + ] + }, + { + "id": "204", + "description": "Violence", + "related": [ + "10016" + ] + }, + { "id": "205", + "description": "Advocacy in General", "related": [ - "10325" + "10325" ] - }, - { + }, + { + "id": "206", + "description": "Guns", + "related": [ + "10017" + ] + }, + { + "id": "207", + "description": "Ammunition", + "related": [ + "10017" + ] + }, + { + "id": "208", + "description": "Knives", + "related": [ + "10017" + ] + }, + { + "id": "209", + "description": "Paintball", + "related": [ + "10393" + ] + }, + { + "id": "210", + "description": "Self-Harm", + "related": [ + "10082" + ] + }, + { "id": "211", + "description": "Abortion", "related": [ - "10001, 10002, 10003" + "10001" ] - }, - { - "id": "20022", + }, + { + "id": "301", + "description": "Adult/Porn", "related": [ - "10015, 10072" + "10009" ] - }, - { - "id": "20054", + }, + { + "id": "302", + "description": "Nudity", "related": [ - "10019, 10020" + "10226" ] - }, - { - "id": "20008", + }, + { + "id": "303", + "description": "Sexual Services", "related": [ - "10120, 10105" + "10226" ] - }, - { - "id": "20091", + }, + { + "id": "304", + "description": "Adult Search/Links", "related": [ - "10094" + "10306" ] - }, - { - "id": "20016", + }, + { + "id": "305", + "description": "Child Abuse", "related": [ - "10234" + "10074" ] - }, - { - "id": "1802", + }, + { + "id": "401", + "description": "Hacking/Cracking", "related": [ - "10415" + "10076" ] - }, - { - "id": "20059", + }, + { + "id": "402", + "description": "Malware", "related": [ - "10144, 10141" + "10295" ] - }, - { - "id": "20053", + }, + { + "id": "403", + "description": "Remote Proxies", "related": [ - "10107, 10146" + "10451" ] - }, - { - "id": "20070", + }, + { + "id": "404", + "description": "Search Engine Caches", "related": [ - "10045" + "10313" ] - }, - { - "id": "20071", + }, + { + "id": "405", + "description": "Translators", "related": [ - "10336" + "10096" ] - }, - { - "id": "20077", + }, + { + "id": "406", + "description": "Remote Desktop/Control", "related": [ - "10329" + "10451" ] - }, - { - "id": "20013", + }, + { + "id": "501", + "description": "Dating", "related": [ - "10050, 10333" + "10283" ] - }, - { - "id": "20004", + }, + { + "id": "502", + "description": "Weddings/Matrimony", "related": [ - "10044, 10337" + "10290" ] - }, - { - "id": "604", + }, + { + "id": "601", + "description": "Market Rates", "related": [ - "10149, 10163" + "10156" ] - }, - { + }, + { + "id": "602", + "description": "Online Trading", + "related": [ + "10156" + ] + }, + { "id": "603", + "description": "Insurance", "related": [ - "10155" + "10155" ] - }, - { + }, + { + "id": "604", + "description": "Finance and Banking", + "related": [ + "10163" + ] + }, + { + "id": "605", + "description": "Cryptocurrency", + "related": [ + "10149" + ] + }, + { + "id": "606", + "description": "Hosted Payment Gateways", + "related": [ + "10368" + ] + }, + { + "id": "701", + "description": "Gambling in General", + "related": [ + "10005" + ] + }, + { + "id": "702", + "description": "Lottery", + "related": [ + "10005" + ] + }, + { "id": "801", + "description": "Online Games", "related": [ - "10279, 10266" + "10266" ] - } - ] + }, + { + "id": "802", + "description": "Games", + "related": [ + "10279" + ] + }, + { + "id": "901", + "description": "Auctions", + "related": [ + "10363" + ] + }, + { + "id": "902", + "description": "Shopping/Retail", + "related": [ + "10370" + ] + }, + { + "id": "903", + "description": "Real Estate", + "related": [ + "10338" + ] + }, + { + "id": "904", + "description": "IT Online Shopping", + "related": [ + "10368" + ] + }, + { + "id": "1001", + "description": "Web Based Chat", + "related": [ + "10086" + ] + }, + { + "id": "1002", + "description": "Instant Messaging", + "related": [ + "10088" + ] + }, + { + "id": "1003", + "description": "Web Based Mail", + "related": [ + "10097" + ] + }, + { + "id": "1004", + "description": "E-Mail Subscription", + "related": [ + "10097" + ] + }, + { + "id": "1005", + "description": "Bulletin Boards", + "related": [ + "10086" + ] + }, + { + "id": "1006", + "description": "IT Bulletin Boards", + "related": [ + "10086" + ] + }, + { + "id": "1007", + "description": "Personal Web Pages/Blogs", + "related": [ + "10090" + ] + }, + { + "id": "1101", + "description": "Downloads", + "related": [ + "10090" + ] + }, + { + "id": "1102", + "description": "Program Downloads", + "related": [ + "10090" + ] + }, + { + "id": "1103", + "description": "Storage Services", + "related": [ + "10449" + ] + }, + { + "id": "1104", + "description": "Streaming Media", + "related": [ + "10127" + ] + }, + { + "id": "1201", + "description": "Employment", + "related": [ + "10066" + ] + }, + { + "id": "1202", + "description": "Career Advancement", + "related": [ + "10067" + ] + }, + { + "id": "1203", + "description": "Side Business", + "related": [ + "10087" + ] + }, + { + "id": "1301", + "description": "Grotesque", + "related": [ + "10306" + ] + }, + { + "id": "1401", + "description": "Special Events", + "related": [ + "10122" + ] + }, + { + "id": "1402", + "description": "Popular Topics", + "related": [ + "10309" + ] + }, + { + "id": "1501", + "description": "Adult Magazine/News", + "related": [ + "10306" + ] + }, + { + "id": "1502", + "description": "Smoking", + "related": [ + "10014" + ] + }, + { + "id": "1503", + "description": "Drinking", + "related": [ + "10168" + ] + }, + { + "id": "1504", + "description": "Alcohol Products", + "related": [ + "10306" + ] + }, + { + "id": "1505", + "description": "Fetish", + "related": [ + "10306" + ] + }, + { + "id": "1506", + "description": "Sexual Expression (text)", + "related": [ + "10226" + ] + }, + { + "id": "1507", + "description": "Costume Play/Enjoyment", + "related": [ + "10306" + ] + }, + { + "id": "1601", + "description": "Occult", + "related": [ + "10348" + ] + }, + { + "id": "1701", + "description": "Home & Family", + "related": [ + "10139" + ] + }, + { + "id": "1801", + "description": "Professional Sports", + "related": [ + "10415" + ] + }, + { + "id": "1802", + "description": "Sports in General", + "related": [ + "10415" + ] + }, + { + "id": "1803", + "description": "Life Events", + "related": [ + "10066" + ] + }, + { + "id": "1901", + "description": "Travel & Tourism", + "related": [ + "10489" + ] + }, + { + "id": "1902", + "description": "Public Agency Tourism", + "related": [ + "10489" + ] + }, + { + "id": "1903", + "description": "Public Transit", + "related": [ + "10044" + ] + }, + { + "id": "1904", + "description": "Accommodations", + "related": [ + "10478" + ] + }, + { + "id": "2001", + "description": "Music and Streaming Audio", + "related": [ + "10126" + ] + }, + { + "id": "2002", + "description": "Horoscope/Astrology/Fortune Telling", + "related": [ + "10352" + ] + }, + { + "id": "2003", + "description": "Entertainer/Celebrity/Pop Culture", + "related": [ + "10121" + ] + }, + { + "id": "2004", + "description": "Dining/Gourmet", + "related": [ + "10172" + ] + }, + { + "id": "2005", + "description": "Entertainment/Venues/Activities", + "related": [ + "10122" + ] + }, + { + "id": "2101", + "description": "Traditional Religions", + "related": [ + "10350" + ] + }, + { + "id": "2102", + "description": "Reilgiions", + "related": [ + "10339" + ] + }, + { + "id": "2201", + "description": "Politics", + "related": [ + "10331" + ] + }, + { + "id": "2301", + "description": "Advertisements/Banners", + "related": [ + "10316" + ] + }, + { + "id": "2302", + "description": "Sweepstakes/Prizes", + "related": [ + "10365" + ] + }, + { + "id": "2303", + "description": "Tracking Sites", + "related": [ + "10452" + ] + }, + { + "id": "2401", + "description": "SPAM", + "related": [ + "10299" + ] + }, + { + "id": "2501", + "description": "News", + "related": [ + "10311" + ] + }, + { + "id": "20004", + "description": "Automotive", + "related": [ + "10044" + ] + }, + { + "id": "20005", + "description": "Business & Commercial", + "related": [ + "10061" + ] + }, + { + "id": "20006", + "description": "Computing & Internet", + "related": [ + "10460" + ] + }, + { + "id": "20008", + "description": "Education", + "related": [ + "10120" + ] + }, + { + "id": "20013", + "description": "Government", + "related": [ + "10050" + ] + }, + { + "id": "20016", + "description": "Health", + "related": [ + "10234" + ] + }, + { + "id": "20017", + "description": "Fitness", + "related": [ + "10206" + ] + }, + { + "id": "20020", + "description": "Internet Telephony", + "related": [ + "10433" + ] + }, + { + "id": "20022", + "description": "Military", + "related": [ + "10015" + ] + }, + { + "id": "20026", + "description": "Peer to Peer/Torrents", + "related": [ + "10083" + ] + }, + { + "id": "20031", + "description": "Recreation & Hobbies", + "related": [ + "10242" + ] + }, + { + "id": "20032", + "description": "Home & Garden", + "related": [ + "10278" + ] + }, + { + "id": "20033", + "description": "Reference", + "related": [ + "10115" + ] + }, + { + "id": "20035", + "description": "Search Engines & Portals", + "related": [ + "10314" + ] + }, + { + "id": "20036", + "description": "Sex Education", + "related": [ + "10013" + ] + }, + { + "id": "20038", + "description": "SMS & Mobile Telephony Services", + "related": [ + "10433" + ] + }, + { + "id": "20039", + "description": "Mobile Apps & Publishers", + "related": [ + "10440" + ] + }, + { + "id": "20048", + "description": "Spyware", + "related": [ + "10300" + ] + }, + { + "id": "20050", + "description": "Content Delivery Networks & Infrastructure", + "related": [ + "10301" + ] + }, + { + "id": "20052", + "description": "Kids Sites", + "related": [ + "10134" + ] + }, + { + "id": "20053", + "description": "Swimsuits & Lingerie", + "related": [ + "10146" + ] + }, + { + "id": "20054", + "description": "Arts & Cultural Events", + "related": [ + "10236" + ] + }, + { + "id": "20055", + "description": "Hosting Sites", + "related": [ + "10458" + ] + }, + { + "id": "20056", + "description": "Philanthropy & Non-Profit Organizations", + "related": [ + "10330" + ] + }, + { + "id": "20057", + "description": "Photo Search & Photo Sharing Sites", + "related": [ + "10307" + ] + }, + { + "id": "20058", + "description": "Ringtones", + "related": [ + "10040" + ] + }, + { + "id": "20059", + "description": "Fashion & Beauty", + "related": [ + "10144" + ] + }, + { + "id": "20060", + "description": "Mobile App Stores", + "related": [ + "10040" + ] + }, + { + "id": "20061", + "description": "Parked Domains", + "related": [ + "10303" + ] + }, + { + "id": "20062", + "description": "Emoticons", + "related": [ + "10086" + ] + }, + { + "id": "20063", + "description": "Mobile Operators", + "related": [ + "10040" + ] + }, + { + "id": "20064", + "description": "Botnets", + "related": [ + "10293" + ] + }, + { + "id": "20065", + "description": "Infected Sites", + "related": [ + "10295" + ] + }, + { + "id": "20066", + "description": "Phishing Sites", + "related": [ + "10298" + ] + }, + { + "id": "20067", + "description": "Keyloggers", + "related": [ + "10300" + ] + }, + { + "id": "20068", + "description": "Mobile Malware", + "related": [ + "10296" + ] + }, + { + "id": "20069", + "description": "No Content", + "related": [ + "10302" + ] + }, + { + "id": "20070", + "description": "Agriculture", + "related": [ + "10045" + ] + }, + { + "id": "20071", + "description": "Architecture", + "related": [ + "10336" + ] + }, + { + "id": "20072", + "description": "Associations/Trade Groups/Unions", + "related": [ + "10325" + ] + }, + { + "id": "20073", + "description": "Books/eBooks", + "related": [ + "10113" + ] + }, + { + "id": "20074", + "description": "BOT Phone Home", + "related": [ + "10293" + ] + }, + { + "id": "20075", + "description": "DDNS", + "related": [ + "10297" + ] + }, + { + "id": "20076", + "description": "Unsupported URL", + "related": [ + "10305" + ] + }, + { + "id": "20077", + "description": "Law", + "related": [ + "10329" + ] + }, + { + "id": "20078", + "description": "Local Communities", + "related": [ + "10087" + ] + }, + { + "id": "20079", + "description": "Miscellaneous", + "related": [ + "10306" + ] + }, + { + "id": "20080", + "description": "Online Magazines", + "related": [ + "10310" + ] + }, + { + "id": "20081", + "description": "Pets/Veterinarian", + "related": [ + "10324" + ] + }, + { + "id": "20082", + "description": "Privacy & Copyright Theft", + "related": [ + "10080" + ] + }, + { + "id": "20083", + "description": "Private IP Addresses", + "related": [ + "10303" + ] + }, + { + "id": "20084", + "description": "Recycling/Environment", + "related": [ + "10051" + ] + }, + { + "id": "20085", + "description": "Science", + "related": [ + "10362" + ] + }, + { + "id": "20086", + "description": "Society & Culture", + "related": [ + "10291" + ] + }, + { + "id": "20087", + "description": "Transport Services & Freight", + "related": [ + "10463" + ] + }, + { + "id": "20088", + "description": "Photography & Film", + "related": [ + "10128" + ] + }, + { + "id": "20089", + "description": "Museums & History", + "related": [ + "10101" + ] + }, + { + "id": "20090", + "description": "eLearning", + "related": [ + "10104" + ] + }, + { + "id": "20091", + "description": "Social Networks", + "related": [ + "10094" + ] + }, + { + "id": "20092", + "description": "DoH/DoT", + "related": [ + "10297" + ] + }, + { + "id": "20093", + "description": "Infrastructure & Backend Services", + "related": [ + "10434" + ] + }, + { + "id": "20094", + "description": "Newly Registered Domains", + "related": [ + "10294" + ] + }, + { + "id": "20095", + "description": "Fireworks", + "related": [ + "10018" + ] + }, + { + "id": "20096", + "description": "Cyberbullying", + "related": [ + "10077" + ] + }, + { + "id": "20097", + "description": "VPN", + "related": [ + "10451" + ] + }, + { + "id": "20098", + "description": "Web Conferencing", + "related": [ + "10442" + ] + }, + { + "id": "20099", + "description": "Fandom", + "related": [ + "10121" + ] + }, + { + "id": "20100", + "description": "Child Safety & Government Help Lines", + "related": [ + "10050" + ] + }, + { + "id": "20101", + "description": "Self Help", + "related": [ + "10224" + ] + }, + { + "id": "20103", + "description": "Code Repositories", + "related": [ + "10429" + ] + }, + { + "id": "20104", + "description": "Cheating", + "related": [ + "10081" + ] + }, + { + "id": "20105", + "description": "Artificial Intelligence", + "related": [ + "10081" + ] + }, + { + "id": "20300", + "description": "Facebook", + "related": [ + "10094" + ] + }, + { + "id": "20301", + "description": "Facebook: Commenting", + "related": [ + "10094" + ] + }, + { + "id": "20302", + "description": "Facebook: Posting", + "related": [ + "10094" + ] + }, + { + "id": "20303", + "description": "Facebook: Friends", + "related": [ + "10094" + ] + }, + { + "id": "20304", + "description": "Facebook: Photo Uploads", + "related": [ + "10091" + ] + }, + { + "id": "20305", + "description": "Facebook: Events", + "related": [ + "10094" + ] + }, + { + "id": "20306", + "description": "Facebook: Apps", + "related": [ + "10094" + ] + }, + { + "id": "20307", + "description": "Facebook: Chat", + "related": [ + "10086" + ] + }, + { + "id": "20308", + "description": "Facebook: Questions", + "related": [ + "10094" + ] + }, + { + "id": "20309", + "description": "Facebook: Video Upload", + "related": [ + "10091" + ] + }, + { + "id": "20310", + "description": "Facebook: Groups", + "related": [ + "10094" + ] + }, + { + "id": "20311", + "description": "Facebook: Games", + "related": [ + "10266" + ] + }, + { + "id": "20330", + "description": "LinkedIn", + "related": [ + "10092" + ] + }, + { + "id": "20331", + "description": "LinkedIn: Updates", + "related": [ + "10092" + ] + }, + { + "id": "20332", + "description": "LinkedIn: Mail", + "related": [ + "10097" + ] + }, + { + "id": "20333", + "description": "LinkedIn: Connections", + "related": [ + "10092" + ] + }, + { + "id": "20334", + "description": "LinkedIn: Jobs", + "related": [ + "10067" + ] + }, + { + "id": "20360", + "description": "Twitter", + "related": [ + "10094" + ] + }, + { + "id": "20362", + "description": "Twitter: Mail", + "related": [ + "10097" + ] + }, + { + "id": "20363", + "description": "Twitter: Follow", + "related": [ + "10094" + ] + }, + { + "id": "20390", + "description": "YouTube", + "related": [ + "10126" + ] + }, + { + "id": "20391", + "description": "YouTube: Commenting", + "related": [ + "10094" + ] + }, + { + "id": "20392", + "description": "YouTube: Video Upload", + "related": [ + "10126" + ] + }, + { + "id": "20393", + "description": "YouTube: Sharing", + "related": [ + "10091" + ] + }, + { + "id": "20420", + "description": "Instagram", + "related": [ + "10094" + ] + }, + { + "id": "20421", + "description": "Instagram: Upload", + "related": [ + "10091" + ] + }, + { + "id": "20422", + "description": "Instagram: Commenting", + "related": [ + "10094" + ] + }, + { + "id": "20423", + "description": "Instagram: Private Message", + "related": [ + "10095" + ] + }, + { + "id": "20450", + "description": "Tumblr", + "related": [ + "10094" + ] + }, + { + "id": "20451", + "description": "Tumblr: Posting", + "related": [ + "10094" + ] + }, + { + "id": "20452", + "description": "Tumblr: Commenting", + "related": [ + "10094" + ] + }, + { + "id": "20453", + "description": "Tumblr: Photo or Video Upload", + "related": [ + "10091" + ] + }, + { + "id": "20480", + "description": "Google+", + "related": [ + "10094" + ] + }, + { + "id": "20481", + "description": "Google+: Posting", + "related": [ + "10094" + ] + }, + { + "id": "20482", + "description": "Google+: Commenting", + "related": [ + "10094" + ] + }, + { + "id": "20483", + "description": "Google+: Photo Upload", + "related": [ + "10091" + ] + }, + { + "id": "20484", + "description": "Google+: Video Upload", + "related": [ + "10091" + ] + }, + { + "id": "20485", + "description": "Google+ Video Chat", + "related": [ + "10086" + ] + }, + { + "id": "20510", + "description": "Pinterest", + "related": [ + "10094" + ] + }, + { + "id": "20511", + "description": "Pinterest: Pin", + "related": [ + "10094" + ] + }, + { + "id": "20512", + "description": "Pinterest: Commenting", + "related": [ + "10094" + ] + }, + { + "id": "20570", + "description": "Ask.fm", + "related": [ + "10094" + ] + }, + { + "id": "20571", + "description": "Ask.fm: Ask", + "related": [ + "10094" + ] + }, + { + "id": "20572", + "description": "Ask.fm: Answer", + "related": [ + "10094" + ] + }, + { + "id": "20630", + "description": "Wordpress", + "related": [ + "10460" + ] + }, + { + "id": "20631", + "description": "Wordpress: Posting", + "related": [ + "10460" + ] + }, + { + "id": "20632", + "description": "Wordpress: Upload", + "related": [ + "10460" + ] + }, + { + "id": "20660", + "description": "TikTok", + "related": [ + "10094" + ] + } +] \ No newline at end of file diff --git a/src/server.js b/src/server.js index 99b9e34..ddb70a6 100644 --- a/src/server.js +++ b/src/server.js @@ -2,14 +2,21 @@ require('dotenv').config() const dgram = require('dgram'); const app = require('./app') +const bodyParser = require('body-parser') const cron = require('./cron') +const express = require('express') +const httpServer = express() +httpServer.use(bodyParser.json()) // for parsing application/json +httpServer.use(bodyParser.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded cron() -const PORT = process.env.PORT +const UDP_PORT = process.env.UDP_PORT +const HTTP_PORT = process.env.HTTP_PORT const server = dgram.createSocket('udp4'); + server.on('error', (err) => { console.log(`Server error:\n${err.stack}`); server.close(); @@ -35,10 +42,34 @@ server.on('message', async (msg, rinfo) => { server.on('listening', () => { const address = server.address(); - console.log(`Server listening ${address.address}:${address.port}`); + console.log(`UDP Server listening ${address.address}:${address.port}`); }); -server.bind(PORT); +server.bind(UDP_PORT); + +httpServer.post('/', async (req, res) => { + try { + const { fqdn } = req.body + + const categories = await app(fqdn) + + let result = {} + + if (categories) + result = { + result: categories + } + + res.status(200).json(JSON.stringify(result)) + } catch (err) { + res.status(500).json(err) + } + +}) + +httpServer.listen(HTTP_PORT, () => { + console.log('HTTP server listening 3333') +}) // Response // {"result":[10009]} \ No newline at end of file