From e60c8a335c57da1770cf16e8429cb469d73e0702 Mon Sep 17 00:00:00 2001 From: Roy Dumblauskas Date: Fri, 14 Nov 2025 17:40:10 -0600 Subject: [PATCH] setup express boilerplate --- backend/.gitignore | 1 + backend/drizzle.config.ts | 12 ++++++++++++ backend/package.json | 2 +- backend/src/index.ts | 22 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 backend/drizzle.config.ts diff --git a/backend/.gitignore b/backend/.gitignore index c2658d7..713d500 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -1 +1,2 @@ node_modules/ +.env diff --git a/backend/drizzle.config.ts b/backend/drizzle.config.ts new file mode 100644 index 0000000..6402161 --- /dev/null +++ b/backend/drizzle.config.ts @@ -0,0 +1,12 @@ +import 'dotenv/config'; +import { defineConfig } from 'drizzle-kit'; + +export default defineConfig({ + out: './drizzle', + schema: './src/db/schema.ts', + dialect: 'postgresql', + dbCredentials: { + url: process.env.DATABASE_URL!, + }, +}); + diff --git a/backend/package.json b/backend/package.json index 2e47fec..e79b844 100644 --- a/backend/package.json +++ b/backend/package.json @@ -4,7 +4,7 @@ "description": "rdumb-blog backend with expressts and drizzle orm", "main": "src/index.ts", "scripts": { - "test": "exit 0" + "start": "npx tsx --env-file=.env --watch src/index.ts" }, "author": "Roy Dumblauskas", "license": "ISC", diff --git a/backend/src/index.ts b/backend/src/index.ts index e69de29..e365049 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -0,0 +1,22 @@ +import 'dotenv/config'; +import { drizzle } from 'drizzle-orm/node-postgres'; +import express, { Request, Response } from "express"; + +// Create a connection to the database +const db = drizzle(process.env.DATABASE_URL!); + +// Create a new express application instance +const app = express(); + +// Set the network port +const port = process.env.PORT || 3000; + +// Define the root path with a greeting message +app.get("/", (req: Request, res: Response) => { + res.json({ message: "Welcome to the Express + TypeScript Server!" }); +}); + +// Start the Express server +app.listen(port, () => { + console.log(`The server is running at http://localhost:${port}`); +});