Skip to content

Commit

Permalink
Temporary Commit (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge authored Dec 3, 2023
1 parent b7e9bbf commit f986290
Show file tree
Hide file tree
Showing 7 changed files with 427 additions and 155 deletions.
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
# If you are cloning this repo, create a copy of this file named `.env` and populate it with your secrets.

# The database URL is used to connect to your PlanetScale database.
# DATABASE_URL=mysql://USERNAME:[email protected]/DATABASE_NAME?ssl={"rejectUnauthorized":true}
DB_HOST='aws.connect.psdb.cloud'
DB_NAME='YOUR_DB_NAME'
DB_USERNAME=''
DB_PASSWORD='pscale_pw_'

# @see https://next-auth.js.org/configuration/options#nextauth_url
AUTH_URL='http://localhost:3000'
AUTH_REDIRECT_PROXY_URL="http://localhost:3001/api"

# You can generate the secret via 'openssl rand -base64 32' on Unix
# @see https://next-auth.js.org/configuration/options#secret
Expand Down
5 changes: 4 additions & 1 deletion apps/nextjs/src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export const env = createEnv({
* built with invalid env vars.
*/
server: {
DATABASE_URL: z.string().url(),
DB_USERNAME: z.string(),
DB_PASSWORD: z.string(),
DB_HOST: z.string(),
DB_NAME: z.string(),
},
/**
* Specify your client-side environment variables schema here.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"engines": {
"node": ">=18.18.2"
},
"packageManager": "pnpm@8.10.5",
"packageManager": "pnpm@8.11.0",
"scripts": {
"build": "turbo build",
"clean": "git clean -xdf node_modules",
Expand Down
22 changes: 13 additions & 9 deletions packages/db/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import * as dotenv from "dotenv";
import type { Config } from "drizzle-kit";

dotenv.config({
path: "../../.env",
});
dotenv.config({ path: "../../.env" });

if (!process.env.DATABASE_URL) {
throw new Error("DATABASE_URL is not set");
}
const uri = [
"mysql://",
process.env.DB_USERNAME,
":",
process.env.DB_PASSWORD,
"@",
process.env.DB_HOST,
":3306/",
process.env.DB_NAME,
'?ssl={"rejectUnauthorized":true}',
].join("");

export default {
schema: "./schema",
driver: "mysql2",
dbCredentials: {
connectionString: process.env.DATABASE_URL,
},
dbCredentials: { uri },
tablesFilter: ["t3turbo_*"],
} satisfies Config;
4 changes: 3 additions & 1 deletion packages/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export * from "drizzle-orm";

export const db = drizzle(
new Client({
url: process.env.DATABASE_URL,
host: process.env.DB_HOST,
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
}).connection(),
{ schema },
);
4 changes: 2 additions & 2 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
},
"dependencies": {
"@planetscale/database": "^1.11.0",
"drizzle-orm": "^0.29.0"
"drizzle-orm": "^0.29.1"
},
"devDependencies": {
"@acme/eslint-config": "workspace:^0.2.0",
"@acme/prettier-config": "workspace:^0.1.0",
"@acme/tsconfig": "workspace:^0.1.0",
"dotenv-cli": "^7.3.0",
"drizzle-kit": "^0.19.13",
"drizzle-kit": "^0.20.6",
"eslint": "^8.53.0",
"prettier": "^3.1.0",
"typescript": "^5.2.2"
Expand Down
Loading

0 comments on commit f986290

Please sign in to comment.