mirror of
https://github.com/tcsenpai/pensieve.git
synced 2025-07-29 06:01:38 +00:00
feat: integrate svelte as spa
This commit is contained in:
parent
881ee18377
commit
4426602393
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ build/
|
||||
*.pyc
|
||||
typesense-data/
|
||||
test-data/
|
||||
static/
|
||||
|
@ -2,6 +2,8 @@ import httpx
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, HTTPException, Depends, status, Query, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.responses import RedirectResponse
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
@ -65,6 +67,23 @@ app.add_middleware(
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.mount("/_app", StaticFiles(directory="static/_app", html=True))
|
||||
|
||||
|
||||
@app.get("/favicon.png", response_class=FileResponse)
|
||||
async def favicon_png():
|
||||
return FileResponse("static/favicon.png")
|
||||
|
||||
|
||||
@app.get("/favicon.ico", response_class=FileResponse)
|
||||
async def favicon_ico():
|
||||
return FileResponse("static/favicon.png")
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def serve_spa():
|
||||
return FileResponse("static/app.html")
|
||||
|
||||
|
||||
def get_db():
|
||||
db = SessionLocal()
|
||||
@ -74,11 +93,6 @@ def get_db():
|
||||
db.close()
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return {"healthy": True}
|
||||
|
||||
|
||||
@app.post("/libraries", response_model=Library, tags=["library"])
|
||||
def new_library(library_param: NewLibraryParam, db: Session = Depends(get_db)):
|
||||
# Check if a library with the same name (case insensitive) already exists
|
||||
|
1306
web/package-lock.json
generated
1306
web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,8 +12,9 @@
|
||||
"format": "prettier --plugin-search-dir . --write ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "^2.0.0",
|
||||
"@sveltejs/kit": "^1.20.4",
|
||||
"@sveltejs/adapter-auto": "^2.1.1",
|
||||
"@sveltejs/adapter-static": "^2.0.3",
|
||||
"@sveltejs/kit": "^1.30.4",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
"@typescript-eslint/parser": "^6.0.0",
|
||||
"autoprefixer": "^10.4.16",
|
||||
@ -24,12 +25,12 @@
|
||||
"postcss": "^8.4.32",
|
||||
"prettier": "^2.8.0",
|
||||
"prettier-plugin-svelte": "^2.10.1",
|
||||
"svelte": "^4.0.5",
|
||||
"svelte": "^4.2.18",
|
||||
"svelte-check": "^3.4.3",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"tailwindcss": "^3.4.4",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^5.0.0",
|
||||
"vite": "^4.4.2"
|
||||
"vite": "^4.5.3"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
|
1
web/src/routes/+layout.ts
Normal file
1
web/src/routes/+layout.ts
Normal file
@ -0,0 +1 @@
|
||||
export const ssr = false;
|
@ -1,17 +1,15 @@
|
||||
import adapter from '@sveltejs/adapter-auto';
|
||||
import { vitePreprocess } from '@sveltejs/kit/vite';
|
||||
import adapter from '@sveltejs/adapter-static';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
|
||||
// for more information about preprocessors
|
||||
preprocess: vitePreprocess(),
|
||||
|
||||
kit: {
|
||||
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
|
||||
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
|
||||
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
|
||||
adapter: adapter()
|
||||
adapter: adapter({
|
||||
pages: '../build',
|
||||
assets: '../build',
|
||||
precompress: false,
|
||||
strict: true,
|
||||
fallback: 'app.html' // may differ from host to host
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user