Skip to content

Commit

Permalink
Changed NODE_ENV to GOD_MODE and other minor tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleyDean committed May 9, 2023
1 parent 8d468c5 commit fbace05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"build-release": "tsc -p tsconfig.release.json",
"clean": "tsc -b --clean && rm -rf build/*",
"serve": "yarn build && node --experimental-json-modules build/main.js",
"serve-dev": "NODE_ENV=development yarn serve",
"serve-dev": "GOD_MODE=true yarn serve",
"refresh-db": "./refresh-db.sh",
"seed-usa": "yarn build && node build/db/import/usa/USADay0Seed.js",
"add-countries": "yarn build && node build/db/utils/jobs/AddCountriesJob.js",
Expand Down
9 changes: 5 additions & 4 deletions src/auth/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import muid, { MUUID } from 'uuid-mongodb'
import { logger } from '../logger.js'
import { AuthUserType } from '../types.js'
import { verifyJWT } from './util.js'

Expand All @@ -8,9 +9,9 @@ import { verifyJWT } from './util.js'
export const createContext = (() => {
let testUUID: MUUID

if (process.env.NODE_ENV === 'development') {
if (process.env.GOD_MODE === 'true') {
testUUID = muid.v4()
console.log(`The user.uuid for this session is: ${testUUID.toString()}`)
logger.info(`The user.uuid for this session is: ${testUUID.toString()}`)
}

return async ({ req }): Promise<any> => {
Expand All @@ -21,8 +22,8 @@ export const createContext = (() => {
uuid: undefined
}

if (process.env.NODE_ENV === 'development' && (user.uuid == null)) {
user.roles = ['admin', 'editor']
if (process.env.GOD_MODE === 'true' && (user.uuid == null)) {
user.roles = ['user_admin','org_admin', 'editor']
user.uuid = testUUID
} else {
const authHeader = String(headers?.authorization ?? '')
Expand Down

0 comments on commit fbace05

Please sign in to comment.