Running tests no docker - Documentation

This commit is contained in:
Damien HENRY 2022-06-05 07:54:08 +02:00
parent 58a3d042ba
commit cd46524019
6 changed files with 80 additions and 35 deletions

26
README.md Normal file
View File

@ -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**

View File

@ -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,20 +17,23 @@ 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"
##########Optional - execute with parameter "optional"
if [ "$1" == "optional" ];then
## Usefull for ... me :)
echo "[Patching]Removing UserReport from application"
## Remove UserReport support
@ -46,4 +50,7 @@ do
if [ "$?" != "0" ];then exit 1;fi
done
echo " [INFO]done"
else
echo "[Patching]UserReport was kept, to remove it, restart : ./patch.sh \"optional\""
fi
##############################

View File

@ -1,9 +0,0 @@
# minimalist Nodejs server for mydraft application (https:/mydraft.cc)
## Swagger
## Installation (Docker)
## Execute
pay **ATTENTION**

0
server/build/.gitkeep Normal file
View File

20
server/start.sh Executable file
View File

@ -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

View File

@ -1 +1,2 @@
/usr/bin/nodejs app.js
#!/bin/bash
cd server && npm install && ./start.sh