social bookmarking for atproto

[backend] Update start process logs

hexmani.ac 3f48e46d f50ab46f

verified
+28 -12
+4 -2
.husky/pre-commit
··· 17 17 run_cmds() { 18 18 desc=$1 19 19 shift 20 + cd "$desc" || FAILED=1 && return 20 21 echo "Running pre-commit checks for $desc..." 21 22 if ! "$@"; then 22 23 echo "ERROR: Pre-commit checks for $desc failed. Aborting commit." 23 24 FAILED=1 24 25 fi 26 + cd .. 25 27 } 26 28 27 - echo "$STAGED" | grep -q "^backend/" && run_cmds "backend" pnpm run fmt && pnpm run lint 29 + echo "$STAGED" | grep -q "^backend/" && run_cmds "backend" pnpm run fmt && run_cmds "backend" pnpm run lint --fix 28 30 git update-index --again 29 31 30 32 echo "$STAGED" | grep -q "^frontend/" && run_cmds "frontend" pnpm run fmt 31 33 git update-index --again 32 34 33 - echo "$STAGED" | grep -q "^lexicons/" && run_cmds "lexicons" pnpm run generate && pnpm run prepublish 35 + echo "$STAGED" | grep -q "^lexicons/" && run_cmds "lexicons" pnpm run generate && run_cmds "lexicons" pnpm run prepublish 34 36 git update-index --again 35 37 36 38 # If any failed, block commit
+6 -7
backend/README.md
··· 1 1 # @clipprjs/server 2 2 3 - TypeScript implementation of the Clippr AppView, using ~~bun~~ NodeJS and Hono. 3 + TypeScript implementation of the Clippr AppView, using ~~Bun~~ NodeJS and Hono. 4 4 5 - > ## Why not Bun? 6 - > We currently aren't using Bun due to some compatibility errors. A migration to Bun is planned in the future, 7 - > preferably before launch. 5 + > **Why not Bun?** We currently aren't using Bun due to some compatibility errors. A migration to 6 + > Bun is planned in the future, preferably before launch. 8 7 9 8 ## Start development server 10 9 ··· 15 14 pnpm run dev 16 15 ``` 17 16 18 - Open http://localhost:9090 and enjoy 19 - 20 17 ## Build for production 21 18 22 19 ```shell ··· 27 24 pnpm run start 28 25 ``` 29 26 27 + Open http://localhost:9090 and enjoy 28 + 30 29 ## current status 31 30 32 31 - ✅ Ingesting content from the firehose (using Jetstream) ··· 36 35 - 🟡 API documentation 37 36 - 🟡 Creating responses to unauthenticated API calls 38 37 - 🟡 Interactions with the frontend 39 - - 🔴 Creating responses to authenticated API calls 38 + - 🔴 Creating responses to authenticated API calls
+1
backend/config.example.toml
··· 26 26 ## NOTE: Storing the database in-memory does not work as the schema is not properly loaded. Fixme! 27 27 [database] 28 28 ## Paths can be used here. 29 + ## It is not recommended to change this if you are using Docker. 29 30 name = "file:clippr.db" 30 31 31 32 ## How the server interacts with the ATproto network.
+14 -1
backend/src/db/database.ts
··· 11 11 const config = Config.getInstance().getConfig(); 12 12 const dbname = config.database.name; 13 13 14 + class DatabaseError extends Error { 15 + constructor(message: string) { 16 + super(message); 17 + this.name = "DatabaseError"; 18 + } 19 + } 20 + 14 21 export class Database { 15 22 private static instance: Database; 16 23 private readonly db; 17 24 18 25 private constructor() { 19 - this.db = drizzle({ connection: { url: `${dbname}` } }); 26 + try { 27 + this.db = drizzle({ connection: { url: `${dbname}` } }); 28 + } catch (e: unknown) { 29 + if (e instanceof Error) { 30 + throw new DatabaseError(e.message); 31 + } else throw new DatabaseError("Unknown error"); 32 + } 20 33 } 21 34 22 35 static getInstance(): Database {
+3 -2
backend/src/main.ts
··· 17 17 18 18 async function main() { 19 19 const logger = Logger; 20 - logger.info("Clippr-BE starting..."); 20 + logger.info(`Clippr-BE v${process.env.npm_package_version} starting...`); 21 21 22 - logger.verbose("Reading configuration..."); 22 + // Config is already loaded into the app (when preparing logger) 23 23 const config = Config.getInstance().getConfig(); 24 24 25 25 logger.verbose("Initializing database..."); ··· 29 29 startFirehose(); 30 30 readFromFirehose(); 31 31 32 + logger.verbose("Starting XRPC server..."); 32 33 const server: ServerType = serve({ 33 34 port: config.port, 34 35 hostname: config.hostname,