mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
chore: prepare cloud merge point with docker and firebase configs in movexe fork Boris account? No, current user.
This commit is contained in:
parent
b38a297349
commit
4a6b335ce3
14 changed files with 263 additions and 2 deletions
5
.firebaserc
Normal file
5
.firebaserc
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"projects": {},
|
||||
"targets": {},
|
||||
"etags": {}
|
||||
}
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -7,4 +7,5 @@ node_modules/
|
|||
.pnpm-store
|
||||
.DS_Store
|
||||
deepagents/
|
||||
debug.log
|
||||
.env.yaml
|
||||
debug.log
|
||||
|
|
|
|||
11
dataconnect/dataconnect.yaml
Normal file
11
dataconnect/dataconnect.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
specVersion: "v1"
|
||||
serviceId: "surfsense-db"
|
||||
location: "us-east4"
|
||||
schemas:
|
||||
- source: "./schema"
|
||||
datasource:
|
||||
postgresql:
|
||||
database: "fdcdb"
|
||||
cloudSql:
|
||||
instanceId: "surfsense-db-fdc"
|
||||
connectorDirs: ["./example"]
|
||||
9
dataconnect/example/connector.yaml
Normal file
9
dataconnect/example/connector.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
connectorId: example
|
||||
generate:
|
||||
javascriptSdk:
|
||||
- outputDir: ..\..\..\..\Antigravity\resources\app\src\dataconnect-generated
|
||||
package: "@dataconnect/generated"
|
||||
packageJsonDir: ..\..\..\..\Antigravity\resources\app
|
||||
react: true
|
||||
angular: false
|
||||
clientCache: {}
|
||||
24
dataconnect/example/mutations.gql
Normal file
24
dataconnect/example/mutations.gql
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
mutation CreateMovie($title: String!, $genre: String!, $imageUrl: String!)
|
||||
@auth(level: USER_EMAIL_VERIFIED, insecureReason: "Any email verified users can create a new movie.") {
|
||||
movie_insert(data: { title: $title, genre: $genre, imageUrl: $imageUrl })
|
||||
}
|
||||
|
||||
mutation UpsertUser($username: String!) @auth(level: USER) {
|
||||
user_upsert(data: { id_expr: "auth.uid", username: $username })
|
||||
}
|
||||
|
||||
mutation AddReview($movieId: UUID!, $rating: Int!, $reviewText: String!)
|
||||
@auth(level: USER) {
|
||||
review_upsert(
|
||||
data: {
|
||||
userId_expr: "auth.uid"
|
||||
movieId: $movieId
|
||||
rating: $rating
|
||||
reviewText: $reviewText
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
mutation DeleteReview($movieId: UUID!) @auth(level: USER) {
|
||||
review_delete(key: { userId_expr: "auth.uid", movieId: $movieId })
|
||||
}
|
||||
67
dataconnect/example/queries.gql
Normal file
67
dataconnect/example/queries.gql
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
query ListMovies @auth(level: PUBLIC, insecureReason: "Anyone can list all movies.") {
|
||||
movies {
|
||||
id
|
||||
title
|
||||
imageUrl
|
||||
genre
|
||||
}
|
||||
}
|
||||
|
||||
query ListUsers @auth(level: NO_ACCESS) {
|
||||
users {
|
||||
id
|
||||
username
|
||||
}
|
||||
}
|
||||
|
||||
query ListUserReviews @auth(level: USER) {
|
||||
user(key: { id_expr: "auth.uid" }) {
|
||||
id
|
||||
username
|
||||
reviews: reviews_on_user {
|
||||
rating
|
||||
reviewDate
|
||||
reviewText
|
||||
movie {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query GetMovieById($id: UUID!) @auth(level: PUBLIC, insecureReason: "Anyone can get a movie by id.") {
|
||||
movie(id: $id) {
|
||||
id
|
||||
title
|
||||
imageUrl
|
||||
genre
|
||||
metadata: movieMetadata_on_movie {
|
||||
rating
|
||||
releaseYear
|
||||
description
|
||||
}
|
||||
reviews: reviews_on_movie {
|
||||
reviewText
|
||||
reviewDate
|
||||
rating
|
||||
user {
|
||||
id
|
||||
username
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query SearchMovie($titleInput: String, $genre: String) @auth(level: PUBLIC, insecureReason: "Anyone can search for movies.") {
|
||||
movies(
|
||||
where: {
|
||||
_and: [{ genre: { eq: $genre } }, { title: { contains: $titleInput } }]
|
||||
}
|
||||
) {
|
||||
id
|
||||
title
|
||||
genre
|
||||
imageUrl
|
||||
}
|
||||
}
|
||||
25
dataconnect/schema/schema.gql
Normal file
25
dataconnect/schema/schema.gql
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
type User @table {
|
||||
id: String! @default(expr: "auth.uid")
|
||||
username: String! @col(dataType: "varchar(50)")
|
||||
}
|
||||
|
||||
type Movie @table {
|
||||
title: String!
|
||||
imageUrl: String!
|
||||
genre: String
|
||||
}
|
||||
|
||||
type MovieMetadata @table {
|
||||
movie: Movie! @unique
|
||||
rating: Float
|
||||
releaseYear: Int
|
||||
description: String
|
||||
}
|
||||
|
||||
type Review @table(name: "Reviews", key: ["movie", "user"]) {
|
||||
user: User!
|
||||
movie: Movie!
|
||||
rating: Int
|
||||
reviewText: String
|
||||
reviewDate: Date! @default(expr: "request.time")
|
||||
}
|
||||
12
dataconnect/seed_data.gql
Normal file
12
dataconnect/seed_data.gql
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
mutation @transaction {
|
||||
movie_insertMany(
|
||||
data: [
|
||||
{
|
||||
id: "550e8400-e29b-41d4-a716-446655440000",
|
||||
title: "Quantum Paradox",
|
||||
imageUrl: "https://firebasestorage.googleapis.com/v0/b/fdc-web-quickstart.appspot.com/o/movie%2Fquantum_paradox.jpeg?alt=media&token=4142e2a1-bf43-43b5-b7cf-6616be3fd4e3",
|
||||
genre: "sci-fi"
|
||||
}
|
||||
]
|
||||
)
|
||||
}
|
||||
21
firebase.json
Normal file
21
firebase.json
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"hosting": {
|
||||
"source": "surfsense_web",
|
||||
"ignore": [
|
||||
"firebase.json",
|
||||
"**/.*",
|
||||
"**/node_modules/**"
|
||||
],
|
||||
"frameworksBackend": {
|
||||
"region": "us-east1"
|
||||
}
|
||||
},
|
||||
"emulators": {
|
||||
"dataconnect": {
|
||||
"dataDir": "dataconnect/.dataconnect/pgliteData"
|
||||
}
|
||||
},
|
||||
"dataconnect": {
|
||||
"source": "dataconnect"
|
||||
}
|
||||
}
|
||||
21
surfsense_backend/.gcloudignore
Normal file
21
surfsense_backend/.gcloudignore
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
.gcloudignore
|
||||
.git
|
||||
.gitignore
|
||||
.venv
|
||||
venv
|
||||
ENV
|
||||
env
|
||||
__pycache__
|
||||
.pytest_cache
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
.env
|
||||
.env.yaml
|
||||
uv.lock
|
||||
pyproject.toml
|
||||
node_modules
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.db
|
||||
data/
|
||||
|
|
@ -30,7 +30,7 @@ def load_uvicorn_config(args=None):
|
|||
config_kwargs = {
|
||||
"app": "app.app:app",
|
||||
"host": os.getenv("UVICORN_HOST", "0.0.0.0"),
|
||||
"port": int(os.getenv("UVICORN_PORT", 8000)),
|
||||
"port": int(os.getenv("UVICORN_PORT", os.getenv("PORT", 8000))),
|
||||
"log_level": os.getenv("UVICORN_LOG_LEVEL", "info"),
|
||||
"reload": args.reload if args else False,
|
||||
"reload_dirs": ["app"] if (args and args.reload) else None,
|
||||
|
|
|
|||
21
surfsense_backend/test_db.py
Normal file
21
surfsense_backend/test_db.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import asyncio
|
||||
import asyncpg
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
async def main():
|
||||
load_dotenv()
|
||||
db_url = os.getenv("DATABASE_URL")
|
||||
if db_url.startswith("postgresql+asyncpg"):
|
||||
db_url = db_url.replace("postgresql+asyncpg", "postgresql")
|
||||
|
||||
print(f"Connecting to {db_url}")
|
||||
try:
|
||||
conn = await asyncpg.connect(db_url)
|
||||
print("SUCCESS: Connected to Neon DB!")
|
||||
await conn.close()
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
25
surfsense_backend/test_db_sa.py
Normal file
25
surfsense_backend/test_db_sa.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import asyncio
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy import text
|
||||
|
||||
async def main():
|
||||
load_dotenv()
|
||||
db_url = os.getenv("DATABASE_URL")
|
||||
db_url = db_url.replace("postgresql+asyncpg", "postgresql+psycopg")
|
||||
if "ssl=require" in db_url:
|
||||
db_url = db_url.replace("ssl=require", "sslmode=require")
|
||||
engine = create_async_engine(db_url)
|
||||
print(f"Connecting to {db_url} using SQLAlchemy async psycopg")
|
||||
try:
|
||||
async with engine.begin() as conn:
|
||||
res = await conn.execute(text("SELECT 1"))
|
||||
print(f"SUCCESS! Result: {res.scalar()}")
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}")
|
||||
finally:
|
||||
await engine.dispose()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
19
surfsense_backend/test_db_sync.py
Normal file
19
surfsense_backend/test_db_sync.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import psycopg
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
def main():
|
||||
load_dotenv()
|
||||
db_url = os.getenv("DATABASE_URL")
|
||||
db_url = db_url.replace("postgresql+asyncpg://", "postgresql://")
|
||||
db_url = db_url.replace("ssl=require", "sslmode=require")
|
||||
|
||||
print(f"Connecting to {db_url} using PSYCOPG")
|
||||
try:
|
||||
with psycopg.connect(db_url) as conn:
|
||||
print("SUCCESS: Connected to Neon DB via Psycopg!")
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue