From cd4652401927c542aca14c197069c966c3a5d72f Mon Sep 17 00:00:00 2001 From: dHENRY Date: Sun, 5 Jun 2022 07:54:08 +0200 Subject: [PATCH] Running tests no docker - Documentation --- README.md | 26 ++++++++++++++++++++ patch.sh | 57 ++++++++++++++++++++++++------------------- server/README.md | 9 ------- server/build/.gitkeep | 0 server/start.sh | 20 +++++++++++++++ start.sh | 3 ++- 6 files changed, 80 insertions(+), 35 deletions(-) create mode 100644 README.md delete mode 100644 server/README.md create mode 100644 server/build/.gitkeep create mode 100755 server/start.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..847a19f --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# Minimalist Nodejs server for mydraft application (https:/mydraft.cc) + +## Installation + +**WARNING** : +This code is not a fork of "mydraftcc/ui" (https://mydraft.cc), the source code of "mydraftcc/ui" must be available at build time (https://github.com/mydraft-cc/ui). +Once the code is retrieved, i apply patches to make the xxx application compatible with the nodejs API server, and (optional) remove the code related to "UserReport". + +### No docker + +``` +# Required +./patch.sh +# if you want to remove UserReport from the application : +#./patch.sh "optional" +cd server && npm install && ./start.sh +#You could set environment parameters in server/start.sh +``` + +### Docker + +## Execute + +## Swagger + +pay **ATTENTION** diff --git a/patch.sh b/patch.sh index e96e5dc..df06463 100755 --- a/patch.sh +++ b/patch.sh @@ -1,14 +1,15 @@ #!/bin/bash - -############### +############################################################## ## D.HENRY (https://www.mytindydc.com) -# Patchs are apply to be API nodejs compliant -# UserReport because i don't want third party in the running app -################################ +# (required) API nodejs compliant +# (Optional) : UserReport because i don't want third party in the running app +# So default is keeping, to remove from source, execute : +# ./patch.sh "optional" +############################################################## -echo "[INFO]Starting applying patchs..." +echo "[INFO]Starting applying patches..." -## Usefull for nodejs-server +## required for nodejs-server match="(const API_URL.*)(https:\/\/api.mydraft.cc)(.*)$" file="ui/src/wireframes/model/actions/loading.ts" echo "[Patching]$match-$file" @@ -16,34 +17,40 @@ echo "[Patching]$match-$file" sed -i -E "s,$match,\1\3," "$file" echo " [INFO]done" -## Usefull for nodejs-server +## required for nodejs-server echo "[Patching]Replacing load route / with /get" sed -i 's,${API_URL}/${args.tokenToRead},${API_URL}/get/${args.tokenToRead},' "$file" if [ "$?" != "0" ];then exit 1;fi echo " [INFO]done" -## Usefull for nodejs-server +## required for nodejs-server ## ContentType ERR Content-Type and application/json (needed for express body-parser) echo "[Patching]ContentType-application/json" sed -i -E "s,ContentType.*text\/json(.*)$,'Content-Type': 'application\/json\1," "$file" if [ "$?" != "0" ];then exit 1;fi echo " [INFO]done" -## Usefull for ... me :) -echo "[Patching]Removing UserReport from application" -## Remove UserReport support -if [ -f "ui/src/core/react/UserReport.tsx" ];then - rm -r ui/src/core/react/UserReport.tsx - if [ "$?" != "0" ];then exit 1;fi -fi -## Patch tsx -files=$(grep -r "UserReport" ui/src | awk -F ":" '{print $1}' |uniq |xargs) -for f in $files -do - echo " [INFO]Patching UserReport in $f" - sed -i -E 's/.*UserReport.*//' "$f" - if [ "$?" != "0" ];then exit 1;fi -done -echo " [INFO]done" +##########Optional - execute with parameter "optional" +if [ "$1" == "optional" ];then + ## Usefull for ... me :) + echo "[Patching]Removing UserReport from application" + ## Remove UserReport support + if [ -f "ui/src/core/react/UserReport.tsx" ];then + rm -r ui/src/core/react/UserReport.tsx + if [ "$?" != "0" ];then exit 1;fi + fi + ## Patch tsx + files=$(grep -r "UserReport" ui/src | awk -F ":" '{print $1}' |uniq |xargs) + for f in $files + do + echo " [INFO]Patching UserReport in $f" + sed -i -E 's/.*UserReport.*//' "$f" + if [ "$?" != "0" ];then exit 1;fi + done + echo " [INFO]done" +else + echo "[Patching]UserReport was kept, to remove it, restart : ./patch.sh \"optional\"" +fi +############################## diff --git a/server/README.md b/server/README.md deleted file mode 100644 index b7c5f70..0000000 --- a/server/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# minimalist Nodejs server for mydraft application (https:/mydraft.cc) - -## Swagger - -## Installation (Docker) - -## Execute - -pay **ATTENTION** diff --git a/server/build/.gitkeep b/server/build/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/server/start.sh b/server/start.sh new file mode 100755 index 0000000..021a0ae --- /dev/null +++ b/server/start.sh @@ -0,0 +1,20 @@ +#!/bin/bash +## those dirs are needed +pwd +for dir in "data logs" +do + if [ -d "$dir" ];then mkdir "$dir";fi +done + +# Where is node or nodejs (alpine <> debian) +NODEJS="/usr/bin/nodejs" +if [ ! -f "$NODEJS" ];then + NODEJS="/usr/bin/node" +fi +## Start application +# Parameters +# listening ip address +# listening port +# Storage: maximum size of the drawing file +# (2Mo : 2 * 1024 * 1024) = 2097152 +IPADDRESS=0.0.0.0 PORT=4000 JSONMAXSIZE=2097152 $NODEJS app.js diff --git a/start.sh b/start.sh index f614911..49fd46e 100755 --- a/start.sh +++ b/start.sh @@ -1 +1,2 @@ -/usr/bin/nodejs app.js +#!/bin/bash +cd server && npm install && ./start.sh \ No newline at end of file