Initial commit.
This commit is contained in:
commit
cb69fea7ac
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/venv
|
14
backend/Dockerfile
Normal file
14
backend/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
FROM python:3.12-alpine
|
||||||
|
|
||||||
|
RUN apk add git
|
||||||
|
WORKDIR /code
|
||||||
|
RUN git clone https://gitea.typename.fr/mikael.capelle/advent-of-code .
|
||||||
|
RUN pip install -e .
|
||||||
|
|
||||||
|
RUN pip install poetry
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
WORKDIR /app
|
||||||
|
RUN poetry install
|
||||||
|
|
||||||
|
CMD ["poetry", "run", "uvicorn", "holt59.aoc.app:app", "--reload", "--proxy-headers", "--host", "0.0.0.0", "--port", "80", "--root-path", "/api/v1"]
|
1166
backend/poetry.lock
generated
Normal file
1166
backend/poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
55
backend/pyproject.toml
Normal file
55
backend/pyproject.toml
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
name = "holt59-aoc-api"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = ""
|
||||||
|
authors = ["Mikaël Capelle <mikael.capelle@gmail.com>"]
|
||||||
|
packages = [{ include = "holt59", from = "src" }]
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = ">=3.10.0,<4.0"
|
||||||
|
fastapi = {extras = ["standard"], version = "^0.115.6"}
|
||||||
|
uvicorn = "^0.32.1"
|
||||||
|
sse-starlette = "^2.1.3"
|
||||||
|
|
||||||
|
[tool.poetry.group.dev.dependencies]
|
||||||
|
ruff = "^0.8.2"
|
||||||
|
pytest = "^8.3.4"
|
||||||
|
pyright = "^1.1.390"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
|
[tool.poe.tasks]
|
||||||
|
format-imports = "ruff check --select I src tests --fix"
|
||||||
|
format-ruff = "ruff format src tests"
|
||||||
|
format.sequence = ["format-imports", "format-ruff"]
|
||||||
|
lint-ruff = "ruff check src tests"
|
||||||
|
lint-ruff-format = "ruff format --check src tests"
|
||||||
|
lint-pyright = "pyright src tests"
|
||||||
|
lint.sequence = ["lint-ruff", "lint-ruff-format", "lint-pyright"]
|
||||||
|
lint.ignore_fail = "return_non_zero"
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
target-version = "py310"
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
extend-select = ["B", "Q", "I"]
|
||||||
|
|
||||||
|
[tool.ruff.lint.flake8-bugbear]
|
||||||
|
extend-immutable-calls = ["fastapi.Depends"]
|
||||||
|
|
||||||
|
[tool.ruff.lint.isort]
|
||||||
|
detect-same-package = true
|
||||||
|
section-order = [
|
||||||
|
"future",
|
||||||
|
"standard-library",
|
||||||
|
"third-party",
|
||||||
|
"first-party",
|
||||||
|
"zik_insat_backend",
|
||||||
|
"local-folder",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.pyright]
|
||||||
|
typeCheckingMode = "strict"
|
||||||
|
reportMissingTypeStubs = true
|
0
backend/src/holt59/aoc/__init__.py
Normal file
0
backend/src/holt59/aoc/__init__.py
Normal file
195
backend/src/holt59/aoc/app.py
Normal file
195
backend/src/holt59/aoc/app.py
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
import asyncio
|
||||||
|
import datetime
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any, Literal, TypeAlias
|
||||||
|
|
||||||
|
from fastapi import FastAPI, Form
|
||||||
|
from sse_starlette import EventSourceResponse
|
||||||
|
|
||||||
|
DataMode: TypeAlias = Literal["holt59", "tests"]
|
||||||
|
|
||||||
|
LOGGER = logging.getLogger("uvicorn.info")
|
||||||
|
|
||||||
|
GIT_AOC_PATH = Path("/code")
|
||||||
|
|
||||||
|
|
||||||
|
def update_repository():
|
||||||
|
subprocess.run(["git", "fetch"], cwd=GIT_AOC_PATH)
|
||||||
|
subprocess.run(["git", "reset", "--hard", "origin/master"], cwd=GIT_AOC_PATH)
|
||||||
|
|
||||||
|
|
||||||
|
def read_head_commit():
|
||||||
|
# read git commit
|
||||||
|
process = subprocess.run(
|
||||||
|
["git", "log", "-1", '--format="%H"'], cwd=GIT_AOC_PATH, stdout=subprocess.PIPE
|
||||||
|
)
|
||||||
|
return process.stdout.decode("utf-8").strip()[1:-1]
|
||||||
|
|
||||||
|
|
||||||
|
def read_test_file(year: int, day: int, mode: DataMode) -> str:
|
||||||
|
path = GIT_AOC_PATH.joinpath(f"src/holt59/aoc/inputs/{mode}/{year}/day{day}.txt")
|
||||||
|
if not path.exists():
|
||||||
|
return ""
|
||||||
|
|
||||||
|
with open(path, "r") as fp:
|
||||||
|
return fp.read()
|
||||||
|
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/update")
|
||||||
|
def update():
|
||||||
|
update_repository()
|
||||||
|
head_commit = read_head_commit()
|
||||||
|
LOGGER.info(f"repository now at {head_commit}")
|
||||||
|
return {"HEAD": head_commit}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/data")
|
||||||
|
async def data(year: int, day: int, mode: DataMode = "tests"):
|
||||||
|
return {"content": read_test_file(year, day, mode)}
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/submit-sse")
|
||||||
|
async def submit_sse(year: int = Form(), day: int = Form(), input: str = Form()):
|
||||||
|
data = input.rstrip().replace("\r\n", "\n")
|
||||||
|
|
||||||
|
process = await asyncio.create_subprocess_exec(
|
||||||
|
"holt59-aoc",
|
||||||
|
"--stdin",
|
||||||
|
"--api",
|
||||||
|
"--year",
|
||||||
|
str(year),
|
||||||
|
str(day),
|
||||||
|
stdout=asyncio.subprocess.PIPE,
|
||||||
|
stderr=asyncio.subprocess.PIPE,
|
||||||
|
stdin=asyncio.subprocess.PIPE,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert process.stdin is not None
|
||||||
|
assert process.stdout is not None
|
||||||
|
assert process.stderr is not None
|
||||||
|
|
||||||
|
message_queue: asyncio.Queue[dict[str, Any]] = asyncio.Queue()
|
||||||
|
|
||||||
|
async def watch_stream(
|
||||||
|
fp: asyncio.StreamReader, stream: Literal["stdout", "stderr"]
|
||||||
|
):
|
||||||
|
while True:
|
||||||
|
output = await fp.readline()
|
||||||
|
if output == b"":
|
||||||
|
break
|
||||||
|
await message_queue.put(
|
||||||
|
{
|
||||||
|
"type": "stream",
|
||||||
|
"stream": stream,
|
||||||
|
"data": json.loads(output)
|
||||||
|
if stream == "stdout"
|
||||||
|
else {"type": "error", "message": output.decode("utf-8")},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
async def run():
|
||||||
|
assert process.stdin is not None
|
||||||
|
assert process.stdout is not None
|
||||||
|
assert process.stderr is not None
|
||||||
|
|
||||||
|
await message_queue.put(
|
||||||
|
{
|
||||||
|
"type": "start",
|
||||||
|
"data": {
|
||||||
|
"time": datetime.datetime.now().isoformat(),
|
||||||
|
"commit": read_head_commit(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
process.stdin.write(data.encode("utf-8"))
|
||||||
|
await process.stdin.drain()
|
||||||
|
process.stdin.close()
|
||||||
|
|
||||||
|
await asyncio.gather(
|
||||||
|
# process.stdin.drain(),
|
||||||
|
watch_stream(process.stdout, "stdout"),
|
||||||
|
watch_stream(process.stderr, "stderr"),
|
||||||
|
)
|
||||||
|
|
||||||
|
returncode: int | None = None
|
||||||
|
try:
|
||||||
|
returncode = await asyncio.wait_for(process.wait(), timeout=300)
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
...
|
||||||
|
|
||||||
|
await message_queue.put(
|
||||||
|
{
|
||||||
|
"type": "complete",
|
||||||
|
"data": {
|
||||||
|
"status": "success" if returncode is not None else "error",
|
||||||
|
"returncode": -1 if returncode is None else -1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
await message_queue.join()
|
||||||
|
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.create_task(run())
|
||||||
|
|
||||||
|
async def stream_queue():
|
||||||
|
while True:
|
||||||
|
message = await message_queue.get()
|
||||||
|
|
||||||
|
yield json.dumps(
|
||||||
|
{
|
||||||
|
"event": message["type"],
|
||||||
|
"id": 0,
|
||||||
|
"retry": 0,
|
||||||
|
"data": message["data"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
message_queue.task_done()
|
||||||
|
|
||||||
|
if message["type"] == "complete":
|
||||||
|
break
|
||||||
|
|
||||||
|
return EventSourceResponse(stream_queue())
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/submit")
|
||||||
|
async def submit(
|
||||||
|
year: int = Form(), day: int = Form(), verbose: bool = Form(), input: str = Form()
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
data = input.strip().replace("\r\n", "\n")
|
||||||
|
|
||||||
|
args: list[str] = ["holt59-aoc", "--stdin"]
|
||||||
|
if verbose:
|
||||||
|
args += ["-v"]
|
||||||
|
|
||||||
|
start = datetime.datetime.now()
|
||||||
|
process = subprocess.run(
|
||||||
|
args + ["--year", str(year), str(day)],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
input=data.encode("utf-8"),
|
||||||
|
timeout=300,
|
||||||
|
)
|
||||||
|
time = datetime.datetime.now() - start
|
||||||
|
|
||||||
|
return {
|
||||||
|
"commit": read_head_commit(),
|
||||||
|
"input": data,
|
||||||
|
"error": process.returncode != 0,
|
||||||
|
"stdout": process.stdout.decode("utf-8"),
|
||||||
|
"stderr": process.stderr.decode("utf-8"),
|
||||||
|
"time": time.total_seconds(),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
async def root():
|
||||||
|
return {"message": "Hello World"}
|
31
docker-compose.yml
Normal file
31
docker-compose.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
services:
|
||||||
|
|
||||||
|
api:
|
||||||
|
restart: unless-stopped
|
||||||
|
build: backend
|
||||||
|
volumes:
|
||||||
|
- ./backend:/app:ro
|
||||||
|
expose:
|
||||||
|
- 80
|
||||||
|
|
||||||
|
server:
|
||||||
|
image: nginx:stable
|
||||||
|
restart: unless-stopped
|
||||||
|
links:
|
||||||
|
- api
|
||||||
|
environment:
|
||||||
|
- VIRTUAL_HOST=aoc.typename.fr
|
||||||
|
- API_URL=http://api:80
|
||||||
|
volumes:
|
||||||
|
- ./nginx.conf:/etc/nginx/templates/default.conf.template:ro
|
||||||
|
- ./front/dist:/www/data:ro
|
||||||
|
expose:
|
||||||
|
- 80
|
||||||
|
networks:
|
||||||
|
proxy:
|
||||||
|
default:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
proxy:
|
||||||
|
name: nginxproxy
|
||||||
|
external: true
|
12
front/.dockerignore
Normal file
12
front/.dockerignore
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
*
|
||||||
|
!env.d.ts
|
||||||
|
!src
|
||||||
|
!public
|
||||||
|
!yarn.lock
|
||||||
|
!package.json
|
||||||
|
!index.html
|
||||||
|
!vite.config.ts
|
||||||
|
!tsconfig.json
|
||||||
|
!tsconfig.app.json
|
||||||
|
!tsconfig.node.json
|
||||||
|
!tsconfig.vitest.json
|
6
front/.editorconfig
Normal file
6
front/.editorconfig
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}]
|
||||||
|
charset = utf-8
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
30
front/.gitignore
vendored
Normal file
30
front/.gitignore
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
coverage
|
||||||
|
*.local
|
||||||
|
|
||||||
|
/cypress/videos/
|
||||||
|
/cypress/screenshots/
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
|
||||||
|
*.tsbuildinfo
|
7
front/.prettierrc.json
Normal file
7
front/.prettierrc.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/prettierrc",
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 100
|
||||||
|
}
|
8
front/.vscode/extensions.json
vendored
Normal file
8
front/.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"Vue.volar",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"EditorConfig.EditorConfig",
|
||||||
|
"esbenp.prettier-vscode"
|
||||||
|
]
|
||||||
|
}
|
11
front/Dockerfile
Normal file
11
front/Dockerfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
FROM node:23-alpine as builder
|
||||||
|
|
||||||
|
WORKDIR /tmp/app
|
||||||
|
COPY . /tmp/app
|
||||||
|
|
||||||
|
RUN yarn install --frozen-lockfile
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
FROM nginx:stable
|
||||||
|
|
||||||
|
COPY --from=builder /tmp/app/dist /www/data
|
39
front/README.md
Normal file
39
front/README.md
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# holt59-aoc
|
||||||
|
|
||||||
|
This template should help get you started developing with Vue 3 in Vite.
|
||||||
|
|
||||||
|
## Recommended IDE Setup
|
||||||
|
|
||||||
|
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
||||||
|
|
||||||
|
## Type Support for `.vue` Imports in TS
|
||||||
|
|
||||||
|
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
|
||||||
|
|
||||||
|
## Customize configuration
|
||||||
|
|
||||||
|
See [Vite Configuration Reference](https://vite.dev/config/).
|
||||||
|
|
||||||
|
## Project Setup
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compile and Hot-Reload for Development
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Type-Check, Compile and Minify for Production
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lint with [ESLint](https://eslint.org/)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn lint
|
||||||
|
```
|
1
front/env.d.ts
vendored
Normal file
1
front/env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
19
front/eslint.config.js
Normal file
19
front/eslint.config.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import pluginVue from 'eslint-plugin-vue'
|
||||||
|
import vueTsEslintConfig from '@vue/eslint-config-typescript'
|
||||||
|
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
name: 'app/files-to-lint',
|
||||||
|
files: ['**/*.{ts,mts,tsx,vue}'],
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'app/files-to-ignore',
|
||||||
|
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
|
||||||
|
},
|
||||||
|
|
||||||
|
...pluginVue.configs['flat/essential'],
|
||||||
|
...vueTsEslintConfig(),
|
||||||
|
skipFormatting,
|
||||||
|
]
|
16
front/index.html
Normal file
16
front/index.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="h-100">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Holt59 - AOC</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="h-100" data-bs-theme="dark">
|
||||||
|
<div id="app" class="d-flex flex-column h-100"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
47
front/package.json
Normal file
47
front/package.json
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "holt59-aoc",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"build-only": "vite build",
|
||||||
|
"type-check": "vue-tsc --build",
|
||||||
|
"lint": "eslint . --fix",
|
||||||
|
"format": "prettier --write src/"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"bootstrap": "^5.3.3",
|
||||||
|
"bootstrap-icons": "^1.11.3",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
|
"luxon": "^3.5.0",
|
||||||
|
"pinia": "^2.2.6",
|
||||||
|
"sse.js": "^2.5.0",
|
||||||
|
"vue": "^3.5.13"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tsconfig/node22": "^22.0.0",
|
||||||
|
"@types/bootstrap": "^5.2.10",
|
||||||
|
"@types/lodash": "^4.17.13",
|
||||||
|
"@types/luxon": "^3.4.2",
|
||||||
|
"@types/node": "^22.9.3",
|
||||||
|
"@vitejs/plugin-vue": "^5.2.1",
|
||||||
|
"@vue/eslint-config-prettier": "^10.1.0",
|
||||||
|
"@vue/eslint-config-typescript": "^14.1.3",
|
||||||
|
"@vue/tsconfig": "^0.7.0",
|
||||||
|
"eslint": "^9.14.0",
|
||||||
|
"eslint-plugin-vue": "^9.30.0",
|
||||||
|
"npm-run-all2": "^7.0.1",
|
||||||
|
"prettier": "^3.3.3",
|
||||||
|
"sass": "1.77.6",
|
||||||
|
"typescript": "~5.6.3",
|
||||||
|
"vite": "^6.0.1",
|
||||||
|
"vite-plugin-vue-devtools": "^7.6.5",
|
||||||
|
"vue-tsc": "^2.1.10"
|
||||||
|
},
|
||||||
|
"resolutions": {
|
||||||
|
"strip-ansi": "^6.0.1"
|
||||||
|
}
|
||||||
|
}
|
BIN
front/public/favicon.ico
Normal file
BIN
front/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
134
front/src/App.vue
Normal file
134
front/src/App.vue
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
|
import ResultVue from '@/components/ResultVue.vue'
|
||||||
|
|
||||||
|
import { loadData } from '@/api';
|
||||||
|
import { range } from 'lodash';
|
||||||
|
import { onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
|
const inAocPeriod = (date: DateTime) => {
|
||||||
|
return !(date.day > 25 || date.month != 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentInput = ref("");
|
||||||
|
const showLogs = ref(false);
|
||||||
|
|
||||||
|
const today = DateTime.now();
|
||||||
|
const maxYear = today.month == 12 ? today.year : today.year - 1;
|
||||||
|
|
||||||
|
const initialDay = ref(inAocPeriod(today) ? today.day : 1);
|
||||||
|
const initialYear = ref(maxYear);
|
||||||
|
|
||||||
|
const currentDay = ref(initialDay.value);
|
||||||
|
const currentYear = ref(maxYear);
|
||||||
|
|
||||||
|
const years = range(2015, maxYear + 1);
|
||||||
|
const days = range(1, 26);
|
||||||
|
|
||||||
|
// handle current day clicked
|
||||||
|
const todayClicked = () => {
|
||||||
|
const today = DateTime.now();
|
||||||
|
|
||||||
|
initialDay.value = inAocPeriod(today) ? today.day : 1;
|
||||||
|
initialYear.value = today.month == 12 ? today.year : today.year - 1;
|
||||||
|
|
||||||
|
currentDay.value = initialDay.value;
|
||||||
|
currentYear.value = initialYear.value;
|
||||||
|
};
|
||||||
|
|
||||||
|
// handle load data + load data of current day on startup
|
||||||
|
const dataLoading = ref(false);
|
||||||
|
const lastInputLoaded = ref("");
|
||||||
|
const lastModeLoaded = ref<"holt59" | "tests">("tests");
|
||||||
|
|
||||||
|
const loadDataClicked = async (mode: "holt59" | "tests" = "tests") => {
|
||||||
|
dataLoading.value = true;
|
||||||
|
currentInput.value = await loadData(currentYear.value, currentDay.value, mode);
|
||||||
|
dataLoading.value = false;
|
||||||
|
|
||||||
|
lastModeLoaded.value = mode;
|
||||||
|
lastInputLoaded.value = currentInput.value;
|
||||||
|
|
||||||
|
};
|
||||||
|
onMounted(loadDataClicked);
|
||||||
|
|
||||||
|
// handle change of day/year
|
||||||
|
watch([currentDay, currentYear], () => {
|
||||||
|
if (currentInput.value == lastInputLoaded.value) {
|
||||||
|
loadDataClicked(lastModeLoaded.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// handle submit
|
||||||
|
const resultComponent = ref<typeof ResultVue>();
|
||||||
|
const submitRunning = ref(false);
|
||||||
|
|
||||||
|
const submitClicked = async () => {
|
||||||
|
submitRunning.value = true;
|
||||||
|
await resultComponent.value!.submit(currentYear.value, currentDay.value, currentInput.value, () => { });
|
||||||
|
submitRunning.value = false;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<nav class="container mt-3">
|
||||||
|
<h1>Advent-Of-Code — Holt59</h1>
|
||||||
|
<hr />
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<ResultVue ref="resultComponent" :show-logs="showLogs" />
|
||||||
|
<section class="container d-flex flex-column flex-grow-1 position-relative">
|
||||||
|
<form method="POST" class="d-flex flex-column flex-grow-1">
|
||||||
|
<div class="row mb-2 align-items-center">
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<button class="form-control btn btn-outline-info" @click.prevent="todayClicked"
|
||||||
|
:disabled="initialYear == currentYear && initialDay == currentDay">Today</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<select class="form-select" autocomplete="off" v-model="currentYear">
|
||||||
|
<option v-for="year in years" :key="year" :value="year">{{ year }}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<select class="form-select" autocomplete="off" v-model="currentDay">
|
||||||
|
<option v-for="day in days" :key="day" :value="day">{{ day }}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<button class="form-control btn btn-success" id="load-data"
|
||||||
|
@click.prevent="() => { loadDataClicked('tests') }"
|
||||||
|
@contextmenu.prevent="() => { loadDataClicked('holt59') }">
|
||||||
|
<span class="spinner-border spinner-border-sm" :class="{ 'd-none': !dataLoading }" role="status"
|
||||||
|
aria-hidden="true"></span>
|
||||||
|
<span class="submit-text" :class="{ 'd-none': dataLoading }">Test Data</span></button>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" id="showLogs" v-model="showLogs">
|
||||||
|
<label class="form-check-label" for="showLogs">
|
||||||
|
Show Logs
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<button type="submit" class="form-control btn btn-primary" @click.prevent="submitClicked">
|
||||||
|
<span class="spinner-border spinner-border-sm" :class="{ 'd-none': !submitRunning }" role="status"
|
||||||
|
aria-hidden="true"></span>
|
||||||
|
<span class="submit-text" :class="{ 'd-none': submitRunning }">Go!</span></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<textarea class="area-input flex-grow-1 w-100" v-model="currentInput"></textarea>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.area-input {
|
||||||
|
resize: none;
|
||||||
|
font-family: var(--bs-font-monospace);
|
||||||
|
font-size: .9em;
|
||||||
|
}
|
||||||
|
</style>
|
50
front/src/api/index.ts
Normal file
50
front/src/api/index.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import { SSE } from 'sse.js';
|
||||||
|
import type { StreamMessage } from './models';
|
||||||
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
|
const API_SUFFIX = "/api/v1";
|
||||||
|
|
||||||
|
export const urlFor = (path: string) => {
|
||||||
|
return window.location.protocol + "//" + window.location.hostname + API_SUFFIX + "/" + path;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const loadData = async (year: number, day: number, mode: "holt59" | "tests") => {
|
||||||
|
const url = new URL(urlFor("data"));
|
||||||
|
url.searchParams.append("year", year.toString());
|
||||||
|
url.searchParams.append("day", day.toString());
|
||||||
|
url.searchParams.append("mode", mode);
|
||||||
|
return await fetch(url, {
|
||||||
|
"method": "GET",
|
||||||
|
}).then(r => r.json()).then(r => r["content"]).catch(() => "");
|
||||||
|
};
|
||||||
|
|
||||||
|
export const submit = async (year: number, day: number, input: string, startCallback: (time: DateTime, commit: string) => void, streamCallback: (message: StreamMessage) => void) => {
|
||||||
|
const data = new FormData();
|
||||||
|
data.append("year", year.toString());
|
||||||
|
data.append("day", day.toString());
|
||||||
|
data.append("input", input.toString());
|
||||||
|
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const eventSource = new SSE(urlFor("submit-sse"), {
|
||||||
|
"start": false,
|
||||||
|
// @ts-expect-error bad typing from SSE
|
||||||
|
"payload": data
|
||||||
|
});
|
||||||
|
|
||||||
|
eventSource.addEventListener('message', function (e: { data: string }) {
|
||||||
|
const data = JSON.parse(e.data);
|
||||||
|
|
||||||
|
if (data.event == "complete") {
|
||||||
|
resolve(null)
|
||||||
|
}
|
||||||
|
else if (data.event == "start") {
|
||||||
|
startCallback(DateTime.fromISO(data.data.time), data.data.commit);
|
||||||
|
}
|
||||||
|
else if (data.event == "stream") {
|
||||||
|
streamCallback(data.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
eventSource.stream();
|
||||||
|
});
|
||||||
|
}
|
48
front/src/api/models.ts
Normal file
48
front/src/api/models.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
type _AnswerStream = {
|
||||||
|
type: "answer";
|
||||||
|
time: string;
|
||||||
|
content: {
|
||||||
|
answer: 1 | 2;
|
||||||
|
answerTime_s: number;
|
||||||
|
totalTime_s: number;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
type _ProgressStream = {
|
||||||
|
type: "progress-start";
|
||||||
|
time: string;
|
||||||
|
content: {
|
||||||
|
counter: number;
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
} | {
|
||||||
|
type: "progress-step";
|
||||||
|
time: string;
|
||||||
|
content: {
|
||||||
|
counter: number;
|
||||||
|
percent: number;
|
||||||
|
}
|
||||||
|
} | {
|
||||||
|
type: "progress-end";
|
||||||
|
time: string;
|
||||||
|
content: {
|
||||||
|
counter: number;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
type _LogStream = {
|
||||||
|
type: "log";
|
||||||
|
time: string;
|
||||||
|
content: {
|
||||||
|
level: "ERROR" | "WARNING" | "INFO" | "DEBUG";
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
type _ErrorStream = {
|
||||||
|
type: "error";
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type StreamMessage = _AnswerStream | _ProgressStream | _LogStream | _ErrorStream;
|
78
front/src/assets/base.css
Normal file
78
front/src/assets/base.css
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/* color palette from <https://github.com/vuejs/theme> */
|
||||||
|
:root {
|
||||||
|
--vt-c-white: #ffffff;
|
||||||
|
--vt-c-white-soft: #f8f8f8;
|
||||||
|
--vt-c-white-mute: #f2f2f2;
|
||||||
|
|
||||||
|
--vt-c-black: #181818;
|
||||||
|
--vt-c-black-soft: #222222;
|
||||||
|
--vt-c-black-mute: #282828;
|
||||||
|
|
||||||
|
--vt-c-indigo: #2c3e50;
|
||||||
|
|
||||||
|
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
|
||||||
|
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
|
||||||
|
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
|
||||||
|
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
|
||||||
|
|
||||||
|
--vt-c-text-light-1: var(--vt-c-indigo);
|
||||||
|
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
|
||||||
|
--vt-c-text-dark-1: var(--vt-c-white);
|
||||||
|
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* semantic color variables for this project */
|
||||||
|
:root {
|
||||||
|
--color-background: var(--vt-c-white);
|
||||||
|
--color-background-soft: var(--vt-c-white-soft);
|
||||||
|
--color-background-mute: var(--vt-c-white-mute);
|
||||||
|
|
||||||
|
--color-border: var(--vt-c-divider-light-2);
|
||||||
|
--color-border-hover: var(--vt-c-divider-light-1);
|
||||||
|
|
||||||
|
--color-heading: var(--vt-c-text-light-1);
|
||||||
|
--color-text: var(--vt-c-text-light-1);
|
||||||
|
|
||||||
|
--section-gap: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--color-background: var(--vt-c-black);
|
||||||
|
--color-background-soft: var(--vt-c-black-soft);
|
||||||
|
--color-background-mute: var(--vt-c-black-mute);
|
||||||
|
|
||||||
|
--color-border: var(--vt-c-divider-dark-2);
|
||||||
|
--color-border-hover: var(--vt-c-divider-dark-1);
|
||||||
|
|
||||||
|
--color-heading: var(--vt-c-text-dark-1);
|
||||||
|
--color-text: var(--vt-c-text-dark-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
min-height: 100vh;
|
||||||
|
color: var(--color-text);
|
||||||
|
background: var(--color-background);
|
||||||
|
transition:
|
||||||
|
color 0.5s,
|
||||||
|
background-color 0.5s;
|
||||||
|
line-height: 1.6;
|
||||||
|
font-family:
|
||||||
|
Inter,
|
||||||
|
-apple-system,
|
||||||
|
BlinkMacSystemFont,
|
||||||
|
'Segoe UI',
|
||||||
|
Roboto,
|
||||||
|
Oxygen,
|
||||||
|
Ubuntu,
|
||||||
|
Cantarell,
|
||||||
|
'Fira Sans',
|
||||||
|
'Droid Sans',
|
||||||
|
'Helvetica Neue',
|
||||||
|
sans-serif;
|
||||||
|
font-size: 15px;
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
39
front/src/assets/bootstrap.scss
vendored
Normal file
39
front/src/assets/bootstrap.scss
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
@use 'sass:map';
|
||||||
|
|
||||||
|
$vt-c-green: #42b883;
|
||||||
|
$primary: $vt-c-green;
|
||||||
|
|
||||||
|
@import '../../node_modules/bootstrap/scss/functions';
|
||||||
|
@import '../../node_modules/bootstrap/scss/variables';
|
||||||
|
@import '../../node_modules/bootstrap/scss/mixins';
|
||||||
|
|
||||||
|
$container-max-widths: map.merge(
|
||||||
|
$container-max-widths,
|
||||||
|
(
|
||||||
|
// 1140px
|
||||||
|
xl: 1140px,
|
||||||
|
|
||||||
|
// 1320px
|
||||||
|
xxl: 1140px
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
@import '../../node_modules/bootstrap/scss/bootstrap';
|
||||||
|
|
||||||
|
*[data-bs-theme='dark'] {
|
||||||
|
.btn-primary,
|
||||||
|
.btn-outline-primary:hover,
|
||||||
|
.btn-outline-primary:focus-visible,
|
||||||
|
.btn-outline-primary:active {
|
||||||
|
color: rgb(43, 48, 53);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*[data-bs-theme='light'] {
|
||||||
|
.btn-primary,
|
||||||
|
.btn-outline-primary:hover,
|
||||||
|
.btn-outline-primary:focus-visible,
|
||||||
|
.btn-outline-primary:active {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
1
front/src/assets/logo.svg
Normal file
1
front/src/assets/logo.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>
|
After Width: | Height: | Size: 276 B |
15
front/src/assets/main.scss
Normal file
15
front/src/assets/main.scss
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
@use 'sass:map';
|
||||||
|
|
||||||
|
@import '../../node_modules/bootstrap/scss/functions';
|
||||||
|
@import '../../node_modules/bootstrap/scss/variables';
|
||||||
|
@import '../../node_modules/bootstrap/scss/mixins';
|
||||||
|
|
||||||
|
#content-div {
|
||||||
|
min-height: 50px;
|
||||||
|
font-family: var(--bs-font-monospace);
|
||||||
|
}
|
||||||
|
|
||||||
|
#content-div>p,
|
||||||
|
#content-div>.progress {
|
||||||
|
margin-bottom: .3rem;
|
||||||
|
}
|
10
front/src/components/ResultProgressLine.vue
Normal file
10
front/src/components/ResultProgressLine.vue
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
defineProps<{
|
||||||
|
progress: number
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div class="progress" role="progressbar" :aria-valuenow="progress" aria-valuemin="0" aria-valuemax="100">
|
||||||
|
<div class="progress-bar" :style="{ 'width': progress + '%' }"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
128
front/src/components/ResultVue.vue
Normal file
128
front/src/components/ResultVue.vue
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
import * as Api from '@/api';
|
||||||
|
import type { StreamMessage } from '@/api/models';
|
||||||
|
import type { DateTime } from 'luxon';
|
||||||
|
import { h, reactive, ref, type Reactive, type VNode } from 'vue';
|
||||||
|
import ResultProgressLine from './ResultProgressLine.vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
showLogs: boolean
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const hasResult = ref(false);
|
||||||
|
const isRunning = ref(false);
|
||||||
|
|
||||||
|
const commitValue = ref("");
|
||||||
|
// const progressValue = ref(-1);
|
||||||
|
|
||||||
|
const answer1Value = ref<string | null>(null);
|
||||||
|
const answer2Value = ref<string | null>(null);
|
||||||
|
|
||||||
|
const contentDiv = ref<HTMLDivElement>();
|
||||||
|
const contentRows = ref<Array<() => VNode>>([]);
|
||||||
|
const contentProgress: Map<number, Reactive<{ progress: number }>> = new Map();
|
||||||
|
const contentErrors = ref("");
|
||||||
|
|
||||||
|
const addRow = (node: () => VNode) => {
|
||||||
|
contentRows.value = contentRows.value.concat(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
const startCallback = (time: DateTime, commit: string) => {
|
||||||
|
hasResult.value = true;
|
||||||
|
commitValue.value = commit;
|
||||||
|
|
||||||
|
addRow(() => h("p", {}, ["Computing part 1... "]));
|
||||||
|
}
|
||||||
|
|
||||||
|
const streamCallback = (message: StreamMessage) => {
|
||||||
|
switch (message.type) {
|
||||||
|
case "progress-start":
|
||||||
|
const progressProps = reactive({ progress: 0 });
|
||||||
|
contentProgress.set(message.content.counter, progressProps);
|
||||||
|
addRow(() => h(ResultProgressLine, progressProps));
|
||||||
|
break;
|
||||||
|
case "progress-step":
|
||||||
|
contentProgress.get(message.content.counter)!.progress = message.content.percent;
|
||||||
|
break;
|
||||||
|
case "progress-end":
|
||||||
|
contentProgress.get(message.content.counter)!.progress = 100;
|
||||||
|
break;
|
||||||
|
case "log":
|
||||||
|
addRow(() => h("p", { "class": { "log": true, "d-none": !props.showLogs } }, [`[${message.content.level}] ${message.time}: ${message.content.message}`]))
|
||||||
|
break;
|
||||||
|
case "error":
|
||||||
|
contentErrors.value = contentErrors.value + message.message;
|
||||||
|
break;
|
||||||
|
case "answer": {
|
||||||
|
const value = message.content.value;
|
||||||
|
if (value.trim().indexOf("\n") >= 0) {
|
||||||
|
addRow(() => h(
|
||||||
|
"p", {}, [`Answer ${message.content.answer} is`,
|
||||||
|
h('pre', {}, [value]),
|
||||||
|
`...found in ${message.content.answerTime_s}s.`]
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addRow(() => h(
|
||||||
|
"p", {}, [`Answer ${message.content.answer} is '${message.content.value}', found in ${message.content.answerTime_s}s.`]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.content.answer == 1) {
|
||||||
|
addRow(() => h("p", {}, ["Computing part 2... "]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const submit = async (year: number, day: number, input: string) => {
|
||||||
|
answer1Value.value = null;
|
||||||
|
answer2Value.value = null;
|
||||||
|
contentErrors.value = "";
|
||||||
|
hasResult.value = false;
|
||||||
|
isRunning.value = true;
|
||||||
|
contentRows.value = [];
|
||||||
|
await Api.submit(year, day, input, startCallback, streamCallback);
|
||||||
|
isRunning.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ submit });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section class="container d-flex flex-column position-relative" :class="{ 'd-none': !hasResult }">
|
||||||
|
<div>
|
||||||
|
<div class="position-absolute" style="top: 0px; right: 12px;">
|
||||||
|
<button class="btn btn-info" type="button" id="btn-clear-output"
|
||||||
|
@click.prevent="() => { hasResult = false }">
|
||||||
|
Clear
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="content" ref="contentDiv" id="content-div">
|
||||||
|
<component :is="() => contentRows.map(row => row())"></component>
|
||||||
|
</div>
|
||||||
|
<code class="stderr text-danger" :class="{ 'd-none': !contentErrors }"><pre>{{ contentErrors }}</pre></code>
|
||||||
|
<p class="text-end"><small>AOC package version <code>{{ commitValue }}</code></small></p>
|
||||||
|
<hr />
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<Teleport to="body">
|
||||||
|
<div class="modal fade" id="logsModal" tabindex="-1" aria-labelledby="logsModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-xl">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h1 class="modal-title fs-5" id="logsModalLabel">Logs</h1>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<code class="stderr text-danger" id="data-logs"><pre>{{ '' }}</pre></code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
14
front/src/main.ts
Normal file
14
front/src/main.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import '@/assets/bootstrap.scss'
|
||||||
|
import '@/assets/main.scss'
|
||||||
|
import 'bootstrap'
|
||||||
|
import 'bootstrap-icons/font/bootstrap-icons.css'
|
||||||
|
|
||||||
|
import { createApp } from 'vue'
|
||||||
|
import { createPinia } from 'pinia'
|
||||||
|
import App from './App.vue'
|
||||||
|
|
||||||
|
const app = createApp(App)
|
||||||
|
|
||||||
|
app.use(createPinia())
|
||||||
|
|
||||||
|
app.mount('#app')
|
12
front/src/stores/counter.ts
Normal file
12
front/src/stores/counter.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { ref, computed } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useCounterStore = defineStore('counter', () => {
|
||||||
|
const count = ref(0)
|
||||||
|
const doubleCount = computed(() => count.value * 2)
|
||||||
|
function increment() {
|
||||||
|
count.value++
|
||||||
|
}
|
||||||
|
|
||||||
|
return { count, doubleCount, increment }
|
||||||
|
})
|
20
front/tsconfig.app.json
Normal file
20
front/tsconfig.app.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||||
|
"include": [
|
||||||
|
"env.d.ts",
|
||||||
|
"src/**/*",
|
||||||
|
"src/**/*.vue"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"src/**/__tests__/*"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"./src/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
front/tsconfig.json
Normal file
11
front/tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.node.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.app.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
20
front/tsconfig.node.json
Normal file
20
front/tsconfig.node.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"extends": "@tsconfig/node22/tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"vite.config.*",
|
||||||
|
"vitest.config.*",
|
||||||
|
"cypress.config.*",
|
||||||
|
"nightwatch.conf.*",
|
||||||
|
"playwright.config.*"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"types": [
|
||||||
|
"node"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
18
front/vite.config.ts
Normal file
18
front/vite.config.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { fileURLToPath, URL } from 'node:url'
|
||||||
|
|
||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||||
|
|
||||||
|
// https://vite.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
vue(),
|
||||||
|
vueDevTools(),
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
2484
front/yarn.lock
Normal file
2484
front/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
40
nginx.conf
Normal file
40
nginx.conf
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
server {
|
||||||
|
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
sendfile on;
|
||||||
|
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_http_version 1.1;
|
||||||
|
gzip_disable "MSIE [1-6]\.";
|
||||||
|
gzip_min_length 256;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
gzip_comp_level 9;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root /www/data;
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /healthy {
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /api/v1 {
|
||||||
|
absolute_redirect off;
|
||||||
|
return 302 /api/v1/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api/v1/ {
|
||||||
|
proxy_pass ${API_URL}/;
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Port $server_port;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user