added monolith app build
This commit is contained in:
parent
911c538fb0
commit
babf31f4f1
25
backend/build-frontend.sh
Executable file
25
backend/build-frontend.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Go to frontend directory
|
||||
cd ../frontend
|
||||
|
||||
# Install dependencies and build
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
# Save swagger-ui.html
|
||||
cd ../backend/src/main/webapp
|
||||
cp swagger-ui.html /tmp/swagger-ui.html
|
||||
|
||||
# Remove old files except WEB-INF
|
||||
find . -mindepth 1 -maxdepth 1 ! -name 'WEB-INF' -exec rm -rf {} +
|
||||
|
||||
# Copy new build files
|
||||
cp -r ../../../../frontend/build/* .
|
||||
|
||||
# Restore swagger-ui.html
|
||||
cp /tmp/swagger-ui.html .
|
||||
rm /tmp/swagger-ui.html
|
||||
|
||||
# Return to backend directory
|
||||
cd ../../../../backend
|
|
@ -0,0 +1,32 @@
|
|||
package ru.akarpov.web4.servlet;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class SPARouterServlet extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
// Set content type
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
|
||||
// Read index.html
|
||||
try (InputStream in = getServletContext().getResourceAsStream("/static/index.html")) {
|
||||
if (in == null) {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy the index.html content to response
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = in.read(buffer)) != -1) {
|
||||
response.getOutputStream().write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
4
backend/src/main/webapp/WEB-INF/jboss-web.xml
Normal file
4
backend/src/main/webapp/WEB-INF/jboss-web.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jboss-web>
|
||||
<context-root>/web-lab4</context-root>
|
||||
</jboss-web>
|
|
@ -8,26 +8,16 @@
|
|||
<welcome-file>index.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
<!-- REST API -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>jakarta.ws.rs.core.Application</servlet-name>
|
||||
<url-pattern>/api/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Add mime type mappings for Swagger UI -->
|
||||
<mime-mapping>
|
||||
<extension>css</extension>
|
||||
<mime-type>text/css</mime-type>
|
||||
</mime-mapping>
|
||||
<mime-mapping>
|
||||
<extension>js</extension>
|
||||
<mime-type>application/javascript</mime-type>
|
||||
</mime-mapping>
|
||||
|
||||
<!-- Allow access to Swagger resources -->
|
||||
<!-- Default Servlet -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>default</servlet-name>
|
||||
<url-pattern>/swagger-ui.html</url-pattern>
|
||||
<url-pattern>/webjars/*</url-pattern>
|
||||
<url-pattern>/</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
</web-app>
|
|
@ -1,65 +0,0 @@
|
|||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Приветственная страница</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Arial', sans-serif;
|
||||
background-color: #f0f2f5;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: white;
|
||||
padding: 2rem;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
max-width: 600px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #1a73e8;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 2em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
p {
|
||||
color: #5f6368;
|
||||
font-size: 1.2em;
|
||||
line-height: 1.5;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.container {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Вы кто такие?</h2>
|
||||
<p>Я вас не звал, идите нахуй!</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
6
frontend/package-lock.json
generated
6
frontend/package-lock.json
generated
|
@ -21,10 +21,10 @@
|
|||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^10.4.20",
|
||||
"postcss": "^8.4.49",
|
||||
"autoprefixer": "^10.4.16",
|
||||
"postcss": "^8.4.32",
|
||||
"react-scripts": "5.0.1",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"tailwindcss": "^3.4.0",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"name": "web-lab4-frontend",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"homepage": ".",
|
||||
"dependencies": {
|
||||
"@reduxjs/toolkit": "^1.9.7",
|
||||
"@types/node": "^16.18.0",
|
||||
|
@ -41,10 +42,10 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^10.4.20",
|
||||
"postcss": "^8.4.49",
|
||||
"autoprefixer": "^10.4.16",
|
||||
"postcss": "^8.4.32",
|
||||
"react-scripts": "5.0.1",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"tailwindcss": "^3.4.0",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
|
@ -1,43 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<base href="%PUBLIC_URL%/" />
|
||||
<title>Web Lab 4</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,17 +1,17 @@
|
|||
import React from 'react';
|
||||
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
|
||||
import { HashRouter as Router, Routes, Route } from 'react-router-dom';
|
||||
import StartPage from './pages/StartPage';
|
||||
import MainPage from './pages/MainPage';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<Router>
|
||||
<Routes>
|
||||
<Route path="/" element={<StartPage />} />
|
||||
<Route path="/main" element={<MainPage />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
);
|
||||
return (
|
||||
<Router>
|
||||
<Routes>
|
||||
<Route path="/" element={<StartPage />} />
|
||||
<Route path="/main" element={<MainPage />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
|
@ -1,8 +1,9 @@
|
|||
import axios from 'axios';
|
||||
import { AuthResponse, LoginRequest, RegisterRequest, Point, PointRequest } from '../types';
|
||||
|
||||
const BASE_PATH = window.location.pathname.split('/')[1]; // Gets 'web-lab4'
|
||||
const api = axios.create({
|
||||
baseURL: 'http://localhost:8080/web-lab4/api',
|
||||
baseURL: `/${BASE_PATH}/api`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user