Merge pull request #6 from usbharu/feature/client

feat: Webクライアントを追加
This commit is contained in:
usbharu 2023-04-14 09:49:44 +09:00 committed by GitHub
commit a3bf8c78bc
10 changed files with 2798 additions and 0 deletions

2
.gitignore vendored
View File

@ -35,3 +35,5 @@ out/
### VS Code ###
.vscode/
*.db
/src/main/resources/static/
/node_modules/

2687
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

19
package.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "hideout",
"version": "1.0.0",
"dependencies": {
"solid-js": "^1.7.3"
},
"devDependencies": {
"typescript": "^5.0.4",
"vite": "^4.2.1",
"vite-plugin-solid": "^2.7.0",
"@suid/vite-plugin": "^0.1.3"
},
"scripts": {
"start": "vite",
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
}
}

View File

@ -90,6 +90,7 @@ fun Application.parent() {
configureKoin(module)
configureHTTP()
configureStaticRouting()
configureMonitoring()
configureSerialization()
register(inject<IUserAuthService>().value)

View File

@ -0,0 +1,21 @@
package dev.usbharu.hideout.plugins
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.http.content.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
fun Application.configureStaticRouting() {
routing {
get("/") {
call.respondText(
String.javaClass.classLoader.getResourceAsStream("static/index.html").readAllBytes().decodeToString(),
contentType = ContentType.Text.Html
)
}
static("/") {
resources("static")
}
}
}

5
src/main/web/App.tsx Normal file
View File

@ -0,0 +1,5 @@
import {Component} from "solid-js";
export const App:Component = () => {
return (<p>aaa</p>)
}

15
src/main/web/index.html Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>Solid App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="/index.tsx" type="module"></script>
</body>
</html>

15
src/main/web/index.tsx Normal file
View File

@ -0,0 +1,15 @@
/* @refresh reload */
import {render} from 'solid-js/web';
// import './index.css';
import {App} from './App';
const root = document.getElementById('root');
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
throw new Error(
'Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got mispelled?',
);
}
render(() => <App/>, root!);

15
tsconfig.json Normal file
View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"strict": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
"types": ["vite/client"],
"noEmit": true,
"isolatedModules": true
}
}

18
vite.config.ts Normal file
View File

@ -0,0 +1,18 @@
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import suidPlugin from "@suid/vite-plugin";
export default defineConfig({
plugins: [solidPlugin(),suidPlugin()],
server: {
port: 3000,
proxy: {
'/api': 'http://localhost:8080'
}
},
root: './src/main/web',
build: {
target: 'esnext',
outDir: '../resources/static',
},
});