Skip to content

Commit

Permalink
Add sandbox for user model + fix body bg
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbaumgertner committed Oct 9, 2024
1 parent 5a27797 commit 9a2e6b4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "next start",
"lint": "next lint",
"format": "prettier --write .",
"run:sandbox": "tsc ./src/_sandbox/createUserRole.ts && node ./src/_sandbox/createUserRole.js"
"run:sandbox": "tsc ./src/_sandbox/index.ts && node ./src/_sandbox/index.js"
},
"engines": {
"node": ">=20"
Expand Down
1 change: 1 addition & 0 deletions src/_sandbox/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './useUserModel'
21 changes: 21 additions & 0 deletions src/_sandbox/useUserModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import mongooseConnect from '../database/mongooseConnect'
import UserModel from '../database/models/User'

async function getUserById(userId: string) {
try {
await mongooseConnect()
const user = await UserModel.findById(userId)
if (!user) {
throw new Error('User not found')
}
return user
} catch (error) {
console.error('Error fetching user:', error)
throw error
}
}

getUserById('66f5a0d1d72e444d6a7e01df').then((user) => {
console.log('user:', user)
return
})
19 changes: 18 additions & 1 deletion src/styles/global.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
:root {
--background-color-light: rgb(255, 255, 255);
--background-color-dark: black;
}

@media (prefers-color-scheme: dark) {
:root {
--background-color: var(--background-color-dark);
}
}

@media (prefers-color-scheme: light) {
:root {
--background-color: var(--background-color-light);
}
}

body {
background-color: rgb(58, 58, 58);
background-color: var(--background-color);
}

0 comments on commit 9a2e6b4

Please sign in to comment.