Skip to content

Commit

Permalink
Get build working in new dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
emwalker committed Oct 19, 2024
1 parent e16d3e4 commit 793ec18
Show file tree
Hide file tree
Showing 26 changed files with 170 additions and 121 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ check-pre-push:
$(MAKE) -C next check-pre-push
test -z "$(shell git status --porcelain)"

check-yarn:
which yarn

dev:
overmind start -f Procfile.dev

Expand Down Expand Up @@ -70,7 +73,7 @@ prod-deploy:
prod-logs:
OVERMIND_SOCKET=./.overmind-logs.sock overmind start -f Procfile.prod-logs

prod-push-deploy: check-git-clean check-pre-push prod-build-containers push-docker push-git prod-deploy
prod-push-deploy: check-yarn check-git-clean check-pre-push prod-build-containers push-docker push-git prod-deploy

prod-build-api:
$(MAKE) -C backend build
Expand All @@ -92,7 +95,6 @@ reset-db:
bash ./scripts/load-production-db
bash ./scripts/make-fixtures
bash ./scripts/promote-fixtures
$(MAKE) -C backend migrate

reset-data-dir:
rm -rf ~/data/digraph-data
Expand Down
3 changes: 1 addition & 2 deletions backend/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ impl Config {
dotenv::from_filename(filename).ok();
}
dotenv::dotenv().ok();

envy::from_env::<Self>().map_err(Error::from)
Ok(envy::from_env::<Self>()?)
}
}
6 changes: 3 additions & 3 deletions backend/src/psql/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl FetchWriteableRepositoriesForUser {
);
let rows = sqlx::query_as::<_, Row>(&query)
.bind(&self.user_id)
.bind(&self.viewer.write_repo_ids.to_vec())
.bind(self.viewer.write_repo_ids.to_vec())
.fetch_all(pool)
.await?;

Expand Down Expand Up @@ -110,7 +110,7 @@ impl Loader<String> for RepositoryLoader {
);
let rows = sqlx::query_as::<_, Row>(&query)
.bind(ids)
.bind(&self.viewer.read_repo_ids.to_vec())
.bind(self.viewer.read_repo_ids.to_vec())
.fetch_all(&self.pool)
.await?;

Expand Down Expand Up @@ -165,7 +165,7 @@ impl SelectRepository {

let row = sqlx::query_as::<_, repository::Row>(&query)
.bind(repo_id)
.bind(&self.actor.write_repo_ids.to_vec())
.bind(self.actor.write_repo_ids.to_vec())
.fetch_one(pool)
.await?;

Expand Down
1 change: 0 additions & 1 deletion backend/src/psql/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::prelude::*;

#[derive(FromRow, Clone, Debug)]
pub struct DatabaseSession {
pub user_id: Uuid,
pub session_id: String,
}

Expand Down
1 change: 0 additions & 1 deletion backend/src/psql/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ impl<'i> UpsertRegisteredUser<'i> {
}

pub struct FetchAccountInfo {
pub viewer: Arc<Viewer>,
pub user_id: String,
}

Expand Down
1 change: 0 additions & 1 deletion backend/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ impl Store {
log::info!("account deletion: fetching account info for {}", user_id);
let psql::FetchAccountInfoResult { personal_repos } = psql::FetchAccountInfo {
user_id: user_id.to_owned(),
viewer: Arc::clone(&self.viewer),
}
.call(&self.db)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"found-relay": "^0.9.1",
"graphql": "^16.8.1",
"http": "^0.0.1-security",
"http-proxy-middleware": "^2.0.6",
"http-proxy-middleware": "^3.0.3",
"immutability-helper": "~3.1.1",
"isomorphic-fetch": "^3.0.0",
"jest-diff": "^29.6.4",
Expand Down
1 change: 0 additions & 1 deletion client/src/server/auth/withGithub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ type Config = Omit<MutationConfig<createGithubSessionMutation>, 'mutation'>

function createSession(environment: Environment, config: Config) {
return commitMutation<createGithubSessionMutation>(
// @ts-expect-error
environment, { ...config, mutation: createGithubSessionQuery },
)
}
Expand Down
34 changes: 19 additions & 15 deletions client/src/server/configureApiProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,34 @@ export default (app: Express) => {
app.post(
'/graphql',
createProxyMiddleware({
target: graphqlApiBaseUrl,
target: `${graphqlApiBaseUrl}/graphql`,
changeOrigin: true,
pathFilter: '/graphql',
secure: false,
onProxyReq(proxyReq, req: IGetUserAuthInfoRequest) {
const { user } = req
on: {
proxyReq(proxyReq, req: IGetUserAuthInfoRequest) {
const { user } = req
console.log('proxyReq config', user)

if (user && user.id && user.sessionId) {
const { id, sessionId } = user
const secret = basicAuthSecret(id, sessionId)
proxyReq.setHeader('Authorization', `Basic ${secret}`)
} else {
console.log('no user found with the request, omitting basic auth header')
}
},
onError(err) {
console.log('problem proxying request to api server:', err)
},
if (user && user.id && user.sessionId) {
const { id, sessionId } = user
const secret = basicAuthSecret(id, sessionId)
proxyReq.setHeader('Authorization', `Basic ${secret}`)
} else {
console.log('no user found with the request, omitting basic auth header')
}
},
error(err) {
console.log('problem proxying request to api server:', err)
},
}
}),
)

app.get(
'/_ah/health',
createProxyMiddleware({
target: graphqlApiBaseUrl,
target: `${graphqlApiBaseUrl}/_ah/health`,
changeOrigin: true,
secure: false,
}),
Expand Down
15 changes: 8 additions & 7 deletions client/src/server/configurePassport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { FetcherBase } from '../FetcherBase'
import { commitMutation } from 'react-relay'
import { Environment, MutationConfig } from 'relay-runtime'

// @ts-expect-error
const RedisStore = store(session)
const redisClient = createClient({
url: process.env.DIGRAPH_NODE_REDIS_URL || 'redis://localhost:6379',
Expand All @@ -32,17 +31,19 @@ export default (app: Express, fetcher: FetcherBase): Express => {
const environment = createEnvironment(fetcher)

app.use(session({
// @ts-expect-error
store: new RedisStore({
client: redisClient,
logErrors: true,
}),
secret: process.env.DIGRAPH_COOKIE_SECRET || 'keyboard cat',
resave: true,
saveUninitialized: true,
secure: process.env.NODE_ENV == 'production',
// Expire in one month
cookie: { maxAge: 1000 * 3600 * 24 * 30 },
cookie: {
// Expire in one month
maxAge: 1000 * 3600 * 24 * 30,
// Only send the cookie over an HTTPS connection
secure: process.env.NODE_ENV == 'production',
},
}))

app
Expand All @@ -65,15 +66,15 @@ export default (app: Express, fetcher: FetcherBase): Express => {

const onCompleted = () => {
console.log('Deleted session for user', req.user?.id)
req.logout()
req.logout(() => { })
res.redirect('/')
}

const onError = (error: Error) => {
const userId = req.user?.id
// eslint-disable-next-line no-console
console.log(`Failed to delete session for user ${userId}`, error)
req.logout()
req.logout(() => { })
}

deleteSession(environment, { variables, onCompleted, onError })
Expand Down
5 changes: 3 additions & 2 deletions client/src/server/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ app
.disable('x-powered-by')
.use(compression())
.use('/static/images', express.static(imagesDir, { maxAge: oneMonth }))
.use('/static', express.static(publicDir, { maxAge: oneMonth }))
.use('/static', express.static(publicDir, { maxAge: oneMonth }))
.use('/robots.txt', (req, res) => {
res.type('text/plain')
res.send('User-agent: *\nAllow: /\n')
Expand All @@ -55,6 +55,7 @@ app.get('*', async (req, res): Promise<void> => {

try {
const preloadedState = { viewer: req.user }
console.log('preloadedState', preloadedState)

if (req.user) {
const { id, sessionId } = req.user
Expand Down Expand Up @@ -82,7 +83,7 @@ app.get('*', async (req, res): Promise<void> => {

const wrapped = (
<Provider store={store}>
{ element }
{element}
</Provider>
)

Expand Down
83 changes: 67 additions & 16 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2559,10 +2559,10 @@
resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz#4fc33a00c1d0c16987b1a20cf92d20614c55ac35"
integrity sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==

"@types/http-proxy@^1.17.8":
version "1.17.9"
resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.9.tgz#7f0e7931343761efde1e2bf48c40f02f3f75705a"
integrity sha512-QsbSjA/fSk7xB+UXlCT3wHBy5ai9wOcNDWwZAtud+jXhwOM3l+EYZh8Lng4+/6n8uar0J7xILzqftJdJ/Wdfkw==
"@types/http-proxy@^1.17.15", "@types/http-proxy@^1.17.8":
version "1.17.15"
resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.15.tgz#12118141ce9775a6499ecb4c01d02f90fc839d36"
integrity sha512-25g5atgiVNTIv0LBDTg1H74Hvayx0ajtJPLLcYE3whFv75J0pWNtOBzaXJQgDTmrX1bx5U9YC2w/n65BN1HwRQ==
dependencies:
"@types/node" "*"

Expand Down Expand Up @@ -2643,7 +2643,14 @@
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10"
integrity sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==

"@types/node@*", "@types/node@^20.8.10":
"@types/node@*":
version "22.7.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.7.tgz#6cd9541c3dccb4f7e8b141b491443f4a1570e307"
integrity sha512-SRxCrrg9CL/y54aiMCG3edPKdprgMVGDXjA3gB8UmmBW5TcXzRUYAh8EWzTnSJFAd1rgImPELza+A3bJ+qxz8Q==
dependencies:
undici-types "~6.19.2"

"@types/node@^20.8.10":
version "20.8.10"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.10.tgz#a5448b895c753ae929c26ce85cab557c6d4a365e"
integrity sha512-TlgT8JntpcbmKUFzjhsyhGfP2fsiz1Mv56im6enJ905xG1DAYesxJaeSbGqQmAw8OWPdhyJGhGSQGKRNJ45u9w==
Expand Down Expand Up @@ -4002,7 +4009,14 @@ braces@^2.3.1:
split-string "^3.0.2"
to-regex "^3.0.1"

braces@^3.0.2, braces@~3.0.2:
braces@^3.0.2, braces@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.1.1"

braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
Expand Down Expand Up @@ -5306,6 +5320,13 @@ debug@^3.2.5, debug@^3.2.6, debug@^3.2.7:
dependencies:
ms "^2.1.1"

debug@^4.3.6:
version "4.3.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52"
integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==
dependencies:
ms "^2.1.3"

decamelize@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
Expand Down Expand Up @@ -6689,10 +6710,10 @@ fill-range@^4.0.0:
repeat-string "^1.6.1"
to-regex-range "^2.1.0"

fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.0.1, fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"

Expand Down Expand Up @@ -6786,9 +6807,9 @@ flatten@^1.0.2:
integrity sha512-dVsPA/UwQ8+2uoFe5GHtiBMu48dWLTdsuEd7CKGlZlD78r1TTWBvDuFaFGKCo/ZfEr95Uk56vZoX86OsHkUeIg==

follow-redirects@^1.0.0:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
version "1.15.9"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1"
integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==

for-each@^0.3.3:
version "0.3.3"
Expand Down Expand Up @@ -7479,7 +7500,7 @@ http-proxy-agent@^5.0.0:
agent-base "6"
debug "4"

http-proxy-middleware@^2.0.3, http-proxy-middleware@^2.0.6:
http-proxy-middleware@^2.0.3:
version "2.0.6"
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f"
integrity sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==
Expand All @@ -7490,6 +7511,18 @@ http-proxy-middleware@^2.0.3, http-proxy-middleware@^2.0.6:
is-plain-obj "^3.0.0"
micromatch "^4.0.2"

http-proxy-middleware@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-3.0.3.tgz#dc1313c75bd00d81e103823802551ee30130ebd1"
integrity sha512-usY0HG5nyDUwtqpiZdETNbmKtw3QQ1jwYFZ9wi5iHzX2BcILwQKtYDJPo7XHTsu5Z0B2Hj3W9NNnbd+AjFWjqg==
dependencies:
"@types/http-proxy" "^1.17.15"
debug "^4.3.6"
http-proxy "^1.18.1"
is-glob "^4.0.3"
is-plain-object "^5.0.0"
micromatch "^4.0.8"

http-proxy@^1.18.1:
version "1.18.1"
resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549"
Expand Down Expand Up @@ -8084,6 +8117,11 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4:
dependencies:
isobject "^3.0.1"

is-plain-object@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344"
integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==

is-potential-custom-element-name@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5"
Expand Down Expand Up @@ -9733,7 +9771,15 @@ micromatch@^3.1.10, micromatch@^3.1.4:
snapdragon "^0.8.1"
to-regex "^3.0.2"

micromatch@^4.0.2, micromatch@^4.0.4:
micromatch@^4.0.2, micromatch@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==
dependencies:
braces "^3.0.3"
picomatch "^2.3.1"

micromatch@^4.0.4:
version "4.0.5"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
Expand Down Expand Up @@ -9922,7 +9968,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

[email protected], ms@^2.1.1:
[email protected], ms@^2.1.1, ms@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
Expand Down Expand Up @@ -14008,6 +14054,11 @@ undici-types@~5.26.4:
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

undici-types@~6.19.2:
version "6.19.8"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==

unicode-canonical-property-names-ecmascript@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc"
Expand Down
Loading

0 comments on commit 793ec18

Please sign in to comment.