Added dev server options
Implemented basic structure for mock service
This commit is contained in:
@@ -18,3 +18,13 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
|||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
EXPOSE 443
|
EXPOSE 443
|
||||||
|
|
||||||
|
|
||||||
|
FROM node:latest as dev
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
COPY . .
|
||||||
|
EXPOSE 8080
|
||||||
|
CMD ["npm", "run", "dev"]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite --host",
|
||||||
"build": "run-p type-check build-only",
|
"build": "run-p type-check build-only",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"build-only": "vite build",
|
"build-only": "vite build",
|
||||||
|
|||||||
53
Frontend/src/components/mock/HeadersComponent.vue
Normal file
53
Frontend/src/components/mock/HeadersComponent.vue
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<script setup>
|
||||||
|
import {ref} from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps(
|
||||||
|
{
|
||||||
|
headersObject : Object
|
||||||
|
}
|
||||||
|
)
|
||||||
|
const headerData = ref( props.headersObject )
|
||||||
|
|
||||||
|
const newHeaderName = ref('');
|
||||||
|
const newHeaderValue = ref('');
|
||||||
|
|
||||||
|
function isHeaderEssential(headerName){
|
||||||
|
return headerName == "Keep-Alive" || headerName == "Connection" || headerName == "Date"
|
||||||
|
}
|
||||||
|
|
||||||
|
function setEssentialHeaderStyle(headerName){
|
||||||
|
return isHeaderEssential(headerName) ? "text-gray-400" : "text-red-400";
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteHeader(index){
|
||||||
|
if(!isHeaderEssential(index)){
|
||||||
|
delete headerData.value[index]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addNewHeader(name, value){
|
||||||
|
headerData.value[name] = value;
|
||||||
|
newHeaderName.value = "";
|
||||||
|
newHeaderValue.value = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="w-full flex">
|
||||||
|
<div class="w-full">Header name</div>
|
||||||
|
<div class="w-full">Header value</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
<div class="flex gap-9 flex-row" v-for="(item, index) in headerData" :key="index">
|
||||||
|
<input type="text" :value="index" class="w-full bg-gray-600 p-2" />
|
||||||
|
<input type="text" :value="item" class="w-full bg-gray-600 p-2" />
|
||||||
|
<button @click="deleteHeader(index)" :class="setEssentialHeaderStyle(index)">X</button>
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-9 flex-row">
|
||||||
|
<input type="text" v-model="newHeaderName" class="w-full p-2 bg-gray-600" />
|
||||||
|
<input type="text" v-model="newHeaderValue" class="w-full p-2 bg-gray-600" />
|
||||||
|
<button class="text-2xl" @click="addNewHeader(newHeaderName, newHeaderValue)" > + </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
0
Frontend/src/components/mock/HistoryComponent.vue
Normal file
0
Frontend/src/components/mock/HistoryComponent.vue
Normal file
@@ -1,10 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<h1>RestMock</h1>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
69
Frontend/src/components/mock/RestMockMessageComponent.vue
Normal file
69
Frontend/src/components/mock/RestMockMessageComponent.vue
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {ref, onBeforeMount , type Ref} from 'vue';
|
||||||
|
import HeadersComponent from './HeadersComponent.vue';
|
||||||
|
|
||||||
|
const clientUUID = ref('');
|
||||||
|
const host = window.location.protocol + "//" + window.location.hostname + "/mock";
|
||||||
|
const mockMessageLink = ref("www.google.com");
|
||||||
|
|
||||||
|
interface mockedMessageData {
|
||||||
|
clientUUID: string;
|
||||||
|
contentType: string;
|
||||||
|
messageBody: object;
|
||||||
|
httpHeaders: object;
|
||||||
|
httpStatus: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const exampleData : mockedMessageData = {
|
||||||
|
clientUUID : "exampleUUID",
|
||||||
|
contentType: "application/json",
|
||||||
|
messageBody: {message: "hello!"},
|
||||||
|
httpHeaders: {Connection:"keep-alive"},
|
||||||
|
httpStatus: 200,
|
||||||
|
}
|
||||||
|
let messageData : Ref<mockedMessageData> = ref(exampleData) ;
|
||||||
|
|
||||||
|
|
||||||
|
onBeforeMount( () => {
|
||||||
|
if ( localStorage.clientUUID != undefined ){
|
||||||
|
clientUUID.value = localStorage.clientUUID;
|
||||||
|
}
|
||||||
|
fetch(host + '/api/mock/' + clientUUID.value).then( response => response.json() ).then(data => putDataInFields(data));
|
||||||
|
} )
|
||||||
|
|
||||||
|
function putDataInFields(data: mockedMessageData){
|
||||||
|
clientUUID.value = data.clientUUID;
|
||||||
|
localStorage.clientUUID = clientUUID.value
|
||||||
|
mockMessageLink.value = host.replace("/mock","/api/mock")+"/r/"+clientUUID.value
|
||||||
|
messageData = ref( data )
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="flex flex-col w-3/5 text-center gap-6">
|
||||||
|
<div>
|
||||||
|
<label for="link">Link</label><br/>
|
||||||
|
<div class="p-2 border-white border-2">
|
||||||
|
<a class="underline" :href="mockMessageLink">{{ mockMessageLink }}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row w-full gap-64">
|
||||||
|
<div class="w-full">
|
||||||
|
<label for="contentType">Content Type</label><br/>
|
||||||
|
<input class="bg-gray-600 w-full" id="contentType" type="text" :value="messageData.contentType"/>
|
||||||
|
</div>
|
||||||
|
<div class=" w-full">
|
||||||
|
<label for="httpStatus">HttpStatus</label><br/>
|
||||||
|
<input class="bg-gray-600 w-full" id="httpStatus" type="text" :value="messageData.httpStatus"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<label for="messageBody">Body</label>
|
||||||
|
<textarea class="bg-gray-600 h-64" id="messageBody" :value="messageData.messageBody.toString()"></textarea>
|
||||||
|
</div>
|
||||||
|
<HeadersComponent :key="JSON.stringify(messageData.httpHeaders)" :headers-object="messageData.httpHeaders"></HeadersComponent>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
@@ -34,6 +34,16 @@ const routes = [
|
|||||||
name: 'xslt',
|
name: 'xslt',
|
||||||
component: () => xsltTool
|
component: () => xsltTool
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/xml/xpath',
|
||||||
|
name: 'xpath',
|
||||||
|
component: () => restMock
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/rest/mock',
|
||||||
|
name: 'restmock',
|
||||||
|
component: () => restMock
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import RestMockComponent from '@components/mock/RestMockComponent.vue'
|
import RestMockMessageComponent from '@components/mock/RestMockMessageComponent.vue'
|
||||||
|
import mockedMessageData from '@components/mock/RestMockMessageComponent.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name:"RestMockView",
|
name:"RestMockView",
|
||||||
components: {RestMockComponent}
|
components: {RestMockMessageComponent}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<RestMockComponent></RestMockComponent>
|
<div class="flex w-full h-screen items-center flex-col">
|
||||||
|
<RestMockMessageComponent></RestMockMessageComponent>
|
||||||
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,27 @@ export default defineConfig({
|
|||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
],
|
],
|
||||||
|
server:{
|
||||||
|
port: 80,
|
||||||
|
host: '0.0.0.0',
|
||||||
|
proxy : {
|
||||||
|
'/java': {
|
||||||
|
target:'http://xmltools-backend:8081/',
|
||||||
|
rewrite: (path) => path.replace(/^\/java/, ''),
|
||||||
|
},
|
||||||
|
'/libxml': {
|
||||||
|
target:'http://xmltools-libxml-backend/',
|
||||||
|
rewrite: (path) => path.replace(/^\/libxml/, ''),
|
||||||
|
},
|
||||||
|
'/mock': {
|
||||||
|
target:'http://xmltools-mocked-services:8097/',
|
||||||
|
rewrite: (path) => path.replace(/^\/mock/, ''),
|
||||||
|
},
|
||||||
|
'/api/mock': {
|
||||||
|
target: 'http://xmltools-mocked-services:8097/'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||||
|
|||||||
75
docker-compose.dev.yml
Normal file
75
docker-compose.dev.yml
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
redis:
|
||||||
|
container_name: xmltools-redis
|
||||||
|
build: ./Redis
|
||||||
|
restart: "no"
|
||||||
|
|
||||||
|
xmltools-frontend:
|
||||||
|
build:
|
||||||
|
context: ./Frontend
|
||||||
|
target: dev
|
||||||
|
container_name: xmltools-frontend
|
||||||
|
image: xmltools-frontend
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
volumes:
|
||||||
|
- ./Frontend:/app
|
||||||
|
- /app/node_modules
|
||||||
|
xmltools-backend:
|
||||||
|
build: ./Backend/tools-services
|
||||||
|
container_name: xmltools-backend
|
||||||
|
image: xmltools-backend
|
||||||
|
ports:
|
||||||
|
- 8081:8081
|
||||||
|
|
||||||
|
xmltools-libxml-backend:
|
||||||
|
build: ./Backend-libXML
|
||||||
|
container_name: xmltools-libxml-backend
|
||||||
|
image: xmltools-libxml-backend
|
||||||
|
ports:
|
||||||
|
- 8082:80
|
||||||
|
|
||||||
|
xmltools-mocked-services:
|
||||||
|
build:
|
||||||
|
context: ./Backend/mocked-services
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: xmltools-mocked-services
|
||||||
|
restart: "no"
|
||||||
|
ports:
|
||||||
|
- "8097:8097"
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
environment:
|
||||||
|
SPRING_PROFILES_ACTIVE: DEV
|
||||||
|
TZ: Europe/Warsaw
|
||||||
|
|
||||||
|
swagger:
|
||||||
|
image: "swaggerapi/swagger-ui:latest"
|
||||||
|
container_name: xmltools-swagger
|
||||||
|
ports:
|
||||||
|
- "8000:8080"
|
||||||
|
environment:
|
||||||
|
- BASE_URL=/swagger
|
||||||
|
- SWAGGER_JSON=/Swagger/swagger.json
|
||||||
|
volumes:
|
||||||
|
- ./Swagger:/Swagger
|
||||||
|
|
||||||
|
filebeat:
|
||||||
|
build: ./Filebeat
|
||||||
|
container_name: xmltools-filebeat
|
||||||
|
user: root
|
||||||
|
volumes:
|
||||||
|
- "./Filebeat/filebeat.docker.yml:/usr/share/filebeat/filebeat.yml:ro"
|
||||||
|
- "/var/lib/docker/containers:/var/lib/docker/containers:ro"
|
||||||
|
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
||||||
|
environment:
|
||||||
|
- ENV_TYPE
|
||||||
|
command:
|
||||||
|
- "-e"
|
||||||
|
- "--strict.perms=false"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: tools_network
|
||||||
@@ -7,7 +7,9 @@ services:
|
|||||||
restart: "no"
|
restart: "no"
|
||||||
|
|
||||||
xmltools-frontend:
|
xmltools-frontend:
|
||||||
build: ./Frontend
|
build:
|
||||||
|
context: ./Frontend
|
||||||
|
target: production-stage
|
||||||
container_name: xmltools-frontend
|
container_name: xmltools-frontend
|
||||||
image: xmltools-frontend
|
image: xmltools-frontend
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ within created container.
|
|||||||
|
|
||||||
## How to run
|
## How to run
|
||||||
|
|
||||||
|
Dev server(with hot-reload frontend): docker-compose -f docker-compose.dev.yml up --build
|
||||||
|
Prod: docker-compose up --build
|
||||||
|
|
||||||
### Localy
|
### Localy
|
||||||
In order to run application use
|
In order to run application use
|
||||||
```aidl
|
```aidl
|
||||||
|
|||||||
Reference in New Issue
Block a user