mirror of
https://github.com/AtHeartEngineering/bandada.git
synced 2026-01-09 20:28:06 -05:00
chore: add project specific .env files, remove environment.ts files
This commit is contained in:
9
.env.build
Normal file
9
.env.build
Normal file
@@ -0,0 +1,9 @@
|
||||
# This file contains build time variables
|
||||
# For FE projects the keys in code would replaced by these values
|
||||
|
||||
# TODO: Set the correct poduction URLs for each
|
||||
|
||||
NX_DEFAULT_NETWORK=goerli
|
||||
NX_API_URL=http://api.zkgroups.org
|
||||
NX_DASHBOARD_URL=http://dashboard.zkgroups.org
|
||||
NX_CLIENT_URL=http://client.zkgroups.org
|
||||
38
.env.example
38
.env.example
@@ -1,39 +1,9 @@
|
||||
# DB
|
||||
DB_URL="dist/data/zk-groups.db"
|
||||
DB_TYPE="sqlite"
|
||||
|
||||
# Jwt
|
||||
JWT_SECRET_KEY="zk_groups_jwt_secret"
|
||||
|
||||
# Session
|
||||
SESSION_SECRET="keyboard cat"
|
||||
|
||||
# Docker
|
||||
DOMAIN=zk-groups
|
||||
DEPLOY_COLOR=""
|
||||
DOCKER_REMOTE_CONTEXT=""
|
||||
DOCKER_DEFAULT_PLATFORM="linux/amd64"
|
||||
|
||||
# Github Passport
|
||||
GITHUB_CLIENT_ID=""
|
||||
GITHUB_CLIENT_SECRET=""
|
||||
|
||||
# Twitter Passport
|
||||
TWITTER_CONSUMER_KEY=""
|
||||
TWITTER_CONSUMER_SECRET=""
|
||||
|
||||
# Reddit Passport
|
||||
REDDIT_CLIENT_ID=""
|
||||
REDDIT_CLIENT_SECRET=""
|
||||
|
||||
# On-chain
|
||||
REPORT_GAS=false
|
||||
BACKEND_PRIVATE_KEY=
|
||||
# Use to create on-chain transactions from api and contracts project
|
||||
INFURA_API_KEY=
|
||||
|
||||
# Wallet used to create on-chain transactions. Default value if the first account in hardhat dev network
|
||||
BACKEND_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
|
||||
|
||||
# The network to be used to save the offchain group merkle roots. This will also be set as default network in FE.
|
||||
# Configuration should be defined in lib/contract-utlis/networks.ts
|
||||
NX_DEFAULT_NETWORK=localhost
|
||||
|
||||
COINMARKETCAP_API_KEY=
|
||||
ETHERSCAN_API_KEY=
|
||||
|
||||
6
.env.local
Normal file
6
.env.local
Normal file
@@ -0,0 +1,6 @@
|
||||
# This file will be loaded during local dev
|
||||
|
||||
NX_DEFAULT_NETWORK=localhost
|
||||
NX_API_URL=http://localhost:3000/api
|
||||
NX_DASHBOARD_URL=http://localhost:3001
|
||||
NX_CLIENT_URL=http://localhost:3002
|
||||
21
apps/api/.env.sample
Normal file
21
apps/api/.env.sample
Normal file
@@ -0,0 +1,21 @@
|
||||
# DB
|
||||
DB_TYPE="postgres"
|
||||
DB_URL="postgres://root:helloworld@localhost:5432/zk-groups"
|
||||
|
||||
# Jwt
|
||||
JWT_SECRET_KEY="zk_groups_jwt_secret"
|
||||
|
||||
# Session
|
||||
SESSION_SECRET="keyboard cat"
|
||||
|
||||
# Github Passport
|
||||
GITHUB_CLIENT_ID=""
|
||||
GITHUB_CLIENT_SECRET=""
|
||||
|
||||
# Twitter Passport
|
||||
TWITTER_CONSUMER_KEY=""
|
||||
TWITTER_CONSUMER_SECRET=""
|
||||
|
||||
# Reddit Passport
|
||||
REDDIT_CLIENT_ID=""
|
||||
REDDIT_CLIENT_SECRET=""
|
||||
@@ -17,13 +17,7 @@
|
||||
"production": {
|
||||
"optimization": true,
|
||||
"extractLicenses": true,
|
||||
"inspect": false,
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "apps/api/src/environments/environment.ts",
|
||||
"with": "apps/api/src/environments/environment.prod.ts"
|
||||
}
|
||||
]
|
||||
"inspect": false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
} from "@nestjs/common"
|
||||
import { AuthGuard } from "@nestjs/passport"
|
||||
import { Request, Response } from "express"
|
||||
import { environment } from "../../environments/environment"
|
||||
|
||||
@Controller("auth")
|
||||
export class AuthController {
|
||||
@@ -30,7 +29,7 @@ export class AuthController {
|
||||
})
|
||||
}
|
||||
|
||||
res.redirect(`${environment.dashboardUrl}/my-groups`)
|
||||
res.redirect(`${process.env.NX_DASHBOARD_URL}/my-groups`)
|
||||
}
|
||||
|
||||
@Get("twitter")
|
||||
@@ -50,7 +49,7 @@ export class AuthController {
|
||||
})
|
||||
}
|
||||
|
||||
res.redirect(`${process.env.DASHBOARD_URL}/my-groups`)
|
||||
res.redirect(`${process.env.NX_DASHBOARD_URL}/my-groups`)
|
||||
}
|
||||
|
||||
@Get("reddit")
|
||||
@@ -70,7 +69,7 @@ export class AuthController {
|
||||
})
|
||||
}
|
||||
|
||||
res.redirect(`${process.env.DASHBOARD_URL}/my-groups`)
|
||||
res.redirect(`${process.env.NX_DASHBOARD_URL}/my-groups`)
|
||||
}
|
||||
|
||||
@Get("getUser")
|
||||
@@ -86,6 +85,6 @@ export class AuthController {
|
||||
httpOnly: true,
|
||||
maxAge: 0
|
||||
})
|
||||
res.redirect(`${environment.dashboardUrl}`)
|
||||
res.redirect(`${process.env.NX_DASHBOARD_URL}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Injectable, Logger } from "@nestjs/common"
|
||||
import { PassportStrategy } from "@nestjs/passport"
|
||||
import { Profile, Strategy } from "passport-github"
|
||||
import { AuthService } from "../auth.service"
|
||||
import { environment } from "../../../environments/environment"
|
||||
|
||||
@Injectable()
|
||||
export class GithubStrategy extends PassportStrategy(Strategy) {
|
||||
@@ -12,7 +11,7 @@ export class GithubStrategy extends PassportStrategy(Strategy) {
|
||||
super({
|
||||
clientID: process.env.GITHUB_CLIENT_ID,
|
||||
clientSecret: process.env.GITHUB_CLIENT_SECRET,
|
||||
callbackURL: `${environment.apiUrl}/auth/github/callback`,
|
||||
callbackURL: `${process.env.NX_API_URL}/auth/github/callback`,
|
||||
profileFields: ["id", "email", "read:user", "user:email"]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Injectable, Logger } from "@nestjs/common"
|
||||
import { PassportStrategy } from "@nestjs/passport"
|
||||
import { Profile, Strategy } from "@zk-groups/passport-reddit"
|
||||
import { environment } from "../../../environments/environment"
|
||||
import { AuthService } from "../auth.service"
|
||||
|
||||
@Injectable()
|
||||
@@ -12,7 +11,7 @@ export class RedditStrategy extends PassportStrategy(Strategy, "reddit") {
|
||||
super({
|
||||
clientID: process.env.REDDIT_CLIENT_ID,
|
||||
clientSecret: process.env.REDDIT_CLIENT_SECRET,
|
||||
callbackURL: `${environment.apiUrl}/api/auth/reddit/callback`
|
||||
callbackURL: `${process.env.NX_API_URL}/auth/reddit/callback`
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Injectable, Logger } from "@nestjs/common"
|
||||
import { PassportStrategy } from "@nestjs/passport"
|
||||
import { Profile, Strategy } from "passport-twitter"
|
||||
import { AuthService } from "../auth.service"
|
||||
import { environment } from "../../../environments/environment"
|
||||
|
||||
@Injectable()
|
||||
export class TwitterStrategy extends PassportStrategy(Strategy, "twitter") {
|
||||
@@ -12,7 +11,7 @@ export class TwitterStrategy extends PassportStrategy(Strategy, "twitter") {
|
||||
super({
|
||||
consumerKey: process.env.TWITTER_CONSUMER_KEY,
|
||||
consumerSecret: process.env.TWITTER_CONSUMER_SECRET,
|
||||
callbackURL: `${environment.apiUrl}/api/auth/twitter/callback`
|
||||
callbackURL: `${process.env.NX_API_URL}/auth/twitter/callback`
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
apiUrl: "",
|
||||
dashboardUrl: ""
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// This file can be replaced during build by using the `fileReplacements` array.
|
||||
// When building for production, this file is replaced with `environment.prod.ts`.
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
apiUrl: "http://localhost:3000/api",
|
||||
dashboardUrl: "http://localhost:3001"
|
||||
}
|
||||
@@ -31,12 +31,6 @@
|
||||
"vendorChunk": true
|
||||
},
|
||||
"production": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "apps/client/src/environments/environment.ts",
|
||||
"with": "apps/client/src/environments/environment.prod.ts"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
apiUrl: ""
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// This file can be replaced during build by using the `fileReplacements` array.
|
||||
// When building for production, this file is replaced with `environment.prod.ts`.
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
apiUrl: "http://localhost:3000/api"
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import { Identity } from "@semaphore-protocol/identity"
|
||||
import { request } from "@zk-groups/utils"
|
||||
import { Signer } from "ethers"
|
||||
import { useCallback, useState } from "react"
|
||||
import { environment } from "../environments/environment"
|
||||
import { Invite } from "../types/invite"
|
||||
|
||||
type ReturnParameters = {
|
||||
@@ -27,7 +26,7 @@ export default function usePermissionedGroups(): ReturnParameters {
|
||||
const getInvite = useCallback(
|
||||
async (inviteCode: string | undefined): Promise<Invite> => {
|
||||
const codeInfo = await request(
|
||||
`${environment.apiUrl}/invites/${inviteCode}`
|
||||
`${process.env.NX_API_URL}/invites/${inviteCode}`
|
||||
)
|
||||
|
||||
return codeInfo
|
||||
@@ -43,7 +42,7 @@ export default function usePermissionedGroups(): ReturnParameters {
|
||||
const identity = new Identity(await signer.signMessage(message))
|
||||
const identityCommitment = identity.getCommitment().toString()
|
||||
const hasJoined = await request(
|
||||
`${environment.apiUrl}/groups/${groupName}/${identityCommitment}`
|
||||
`${process.env.NX_API_URL}/groups/${groupName}/${identityCommitment}`
|
||||
)
|
||||
setHasjoined(hasJoined)
|
||||
setLoading(false)
|
||||
@@ -59,7 +58,7 @@ export default function usePermissionedGroups(): ReturnParameters {
|
||||
inviteCode: string
|
||||
): Promise<void> => {
|
||||
await request(
|
||||
`${environment.apiUrl}/groups/${groupName}/${idCommitment}`,
|
||||
`${process.env.NX_API_URL}/groups/${groupName}/${idCommitment}`,
|
||||
{
|
||||
method: "post",
|
||||
data: {
|
||||
|
||||
@@ -31,12 +31,6 @@
|
||||
"vendorChunk": true
|
||||
},
|
||||
"production": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "apps/dashboard/src/environments/environment.ts",
|
||||
"with": "apps/dashboard/src/environments/environment.prod.ts"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
|
||||
@@ -13,7 +13,6 @@ import { Link, useNavigate } from "react-router-dom"
|
||||
import { useEffect, useState } from "react"
|
||||
import useEthereumWallet from "../hooks/useEthereumWallet"
|
||||
import { request, shortenAddress } from "@zk-groups/utils"
|
||||
import { environment } from "../environments/environment"
|
||||
|
||||
export default function NavBar(): JSX.Element {
|
||||
const navigate = useNavigate()
|
||||
@@ -24,11 +23,11 @@ export default function NavBar(): JSX.Element {
|
||||
const [_account, setAccount] = useState<string>()
|
||||
|
||||
function logOut() {
|
||||
request(`${environment.apiUrl}/auth/log-out`, { method: "post" }).catch(
|
||||
(e) => {
|
||||
console.log("no jwt")
|
||||
}
|
||||
)
|
||||
request(`${process.env.NX_API_URL}/auth/log-out`, {
|
||||
method: "post"
|
||||
}).catch((e) => {
|
||||
console.log("no jwt")
|
||||
})
|
||||
navigate("/")
|
||||
window.location.reload()
|
||||
}
|
||||
@@ -45,7 +44,7 @@ export default function NavBar(): JSX.Element {
|
||||
|
||||
useEffect(() => {
|
||||
;(async () => {
|
||||
await request(`${environment.apiUrl}/auth/getUser`)
|
||||
await request(`${process.env.NX_API_URL}/auth/getUser`)
|
||||
.then((res) => {
|
||||
setJwtInCookies(true)
|
||||
})
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Button, Icon, Link } from "@chakra-ui/react"
|
||||
import { FaGithub, FaRedditAlien, FaTwitter } from "react-icons/fa"
|
||||
import { IconType } from "react-icons/lib"
|
||||
import { environment } from "../environments/environment"
|
||||
|
||||
const SsoIcons: Record<string, IconType> = {
|
||||
Twitter: FaTwitter,
|
||||
@@ -11,7 +10,10 @@ const SsoIcons: Record<string, IconType> = {
|
||||
|
||||
export default function SsoButton(prop: { provider: string }): JSX.Element {
|
||||
return (
|
||||
<Link href={`${environment.apiUrl}/auth/${prop.provider}`} mb="24px">
|
||||
<Link
|
||||
href={`${process.env.NX_API_URL}/auth/${prop.provider}`}
|
||||
mb="24px"
|
||||
>
|
||||
<Button
|
||||
h="44px"
|
||||
bgColor="#FFFFFF"
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
apiUrl: "",
|
||||
clientUrl: ""
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// This file can be replaced during build by using the `fileReplacements` array.
|
||||
// When building for production, this file is replaced with `environment.prod.ts`.
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
apiUrl: "http://localhost:3000/api",
|
||||
clientUrl: "http://localhost:3002"
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { request } from "@zk-groups/utils"
|
||||
import { useCallback } from "react"
|
||||
import { environment } from "../environments/environment"
|
||||
|
||||
type ReturnParameters = {
|
||||
generateMagicLink: (groupName: string) => Promise<string>
|
||||
@@ -9,14 +8,14 @@ type ReturnParameters = {
|
||||
export default function useInvites(): ReturnParameters {
|
||||
const generateMagicLink = useCallback(
|
||||
async (groupName: string): Promise<string> => {
|
||||
const code = await request(`${environment.apiUrl}/invites`, {
|
||||
const code = await request(`${process.env.NX_API_URL}/invites`, {
|
||||
method: "post",
|
||||
data: {
|
||||
groupName
|
||||
}
|
||||
})
|
||||
|
||||
return `${environment.clientUrl}/invites/${code}`
|
||||
return `${process.env.NX_CLIENT_URL}/invites/${code}`
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { request } from "@zk-groups/utils"
|
||||
import { useCallback } from "react"
|
||||
import { environment } from "../environments/environment"
|
||||
import { Group } from "../types/groups"
|
||||
|
||||
type ReturnParameters = {
|
||||
@@ -13,7 +12,7 @@ export default function useMembers(): ReturnParameters {
|
||||
async (groupName: string): Promise<Group | null> => {
|
||||
try {
|
||||
const groupList = await request(
|
||||
`${environment.apiUrl}/groups/${groupName}`
|
||||
`${process.env.NX_API_URL}/groups/${groupName}`
|
||||
)
|
||||
return groupList
|
||||
} catch (e) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { request } from "@zk-groups/utils"
|
||||
import { AxiosRequestConfig } from "axios"
|
||||
import { useCallback } from "react"
|
||||
import { environment } from "../environments/environment"
|
||||
import { Group } from "../types/groups"
|
||||
|
||||
type ReturnParameters = {
|
||||
@@ -19,7 +18,7 @@ export default function useOffchainGroups(): ReturnParameters {
|
||||
> => {
|
||||
try {
|
||||
const groupList = await request(
|
||||
`${environment.apiUrl}/groups/admin-groups`
|
||||
`${process.env.NX_API_URL}/groups/admin-groups`
|
||||
)
|
||||
return groupList
|
||||
} catch (e) {
|
||||
@@ -41,7 +40,7 @@ export default function useOffchainGroups(): ReturnParameters {
|
||||
treeDepth: groupTreeDepth
|
||||
}
|
||||
}
|
||||
await request(`${environment.apiUrl}/groups`, config)
|
||||
await request(`${process.env.NX_API_URL}/groups`, config)
|
||||
|
||||
return true
|
||||
},
|
||||
|
||||
@@ -21,7 +21,6 @@ import { Group } from "../types/groups"
|
||||
import { useNavigate, useSearchParams } from "react-router-dom"
|
||||
import useEthereumWallet from "../hooks/useEthereumWallet"
|
||||
import { request } from "@zk-groups/utils"
|
||||
import { environment } from "../environments/environment"
|
||||
|
||||
export default function MyGroups(): JSX.Element {
|
||||
const [searchParams] = useSearchParams()
|
||||
@@ -47,7 +46,7 @@ export default function MyGroups(): JSX.Element {
|
||||
}
|
||||
|
||||
// Set as off-chain group is user logged in via SSP
|
||||
await request(`${environment.apiUrl}/auth/getUser`)
|
||||
await request(`${process.env.NX_API_URL}/auth/getUser`)
|
||||
.then((res) => {
|
||||
setIsOffchainGroup(true)
|
||||
})
|
||||
|
||||
@@ -39,6 +39,8 @@ services:
|
||||
- REDDIT_CLIENT_ID=sample
|
||||
- REDDIT_CLIENT_SECRET=sample
|
||||
- NX_DEFAULT_NETWORK=localhost
|
||||
- NX_API_URL=http://localhost:3000/api
|
||||
- NX_DASHBOARD_URL=http://localhost:3001
|
||||
- BACKEND_PRIVATE_KEY=
|
||||
- INFURA_API_KEY=
|
||||
ports:
|
||||
|
||||
Reference in New Issue
Block a user