setup express boilerplate
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
|
.env
|
||||||
|
|||||||
@@ -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!,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "rdumb-blog backend with expressts and drizzle orm",
|
"description": "rdumb-blog backend with expressts and drizzle orm",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "exit 0"
|
"start": "npx tsx --env-file=.env --watch src/index.ts"
|
||||||
},
|
},
|
||||||
"author": "Roy Dumblauskas",
|
"author": "Roy Dumblauskas",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
|||||||
@@ -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}`);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user