Skip to content

Commit e9c4493

Browse files
neighbor-peacegeistnine01001101CKatu816
committed
change url
Co-authored-by: Michael Costello <[email protected]> Co-authored-by: Steven Geiger <[email protected]> Co-authored-by: Yufa Li <[email protected]> Co-authored-by: Alexander Tu <[email protected]>
1 parent 9252ec7 commit e9c4493

File tree

3 files changed

+57
-45
lines changed

3 files changed

+57
-45
lines changed

server/routes/index.ts

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,53 @@
11
import { Express, Request, Response, NextFunction } from 'express';
22
import { handleGoogleAuth } from '../controllers/auth.controller';
3-
import { retrieveSchema, saveSchema, userRegistration, verifyUser } from '../controllers/user.controller';
3+
import {
4+
retrieveSchema,
5+
saveSchema,
6+
userRegistration,
7+
verifyUser,
8+
} from '../controllers/user.controller';
49
import { postgresRouter } from './postgres.router';
510
import mysqlRouter from './mysql.router';
611
import session from 'express-session';
7-
declare module "express-session" {
12+
declare module 'express-session' {
813
interface SessionData {
914
user: string;
1015
}
1116
}
12-
import connectRedis from 'connect-redis'
13-
import dotenv from 'dotenv'
17+
import connectRedis from 'connect-redis';
18+
import dotenv from 'dotenv';
1419
dotenv.config();
15-
import Redis from 'ioredis'
16-
import { getCurrentUser } from '../service/session.service'
20+
import Redis from 'ioredis';
21+
import { getCurrentUser } from '../service/session.service';
1722
import path from 'path';
1823

19-
20-
const client_url = process.env.NODE_ENV === 'development' ? process.env.DEV_CLIENT_ENDPOINT : process.env.CLIENT_ENDPOINT
24+
const client_url =
25+
process.env.NODE_ENV === 'development'
26+
? process.env.DEV_CLIENT_ENDPOINT
27+
: process.env.CLIENT_ENDPOINT;
2128

2229
const routes = async (app: Express) => {
23-
// setup UpStash client and Redis store
30+
// setup UpStash client and Redis store
2431
const RedisStore = connectRedis(session);
2532

26-
const client = new Redis(`rediss://:${process.env.REDIS_PASSWORD}@${process.env.REDIS_URL}:${process.env.REDIS_PORT}`)
33+
const client = new Redis(
34+
`rediss://:${process.env.REDIS_PASSWORD}@${process.env.REDIS_URL}:${process.env.REDIS_PORT}`
35+
);
2736

2837
// set session cookie
29-
app.use(session({
30-
store: new RedisStore({ client }),
31-
secret: process.env.REDIS_SECRET as string,
32-
resave: false,
33-
saveUninitialized: true,
34-
cookie: {
35-
secure: process.env.ENVIRONMENT === 'production' ? true : 'auto',
36-
maxAge: 24 * 60 * 60 * 1000,
37-
sameSite: 'lax',
38-
}
39-
}))
38+
app.use(
39+
session({
40+
store: new RedisStore({ client }),
41+
secret: process.env.REDIS_SECRET as string,
42+
resave: false,
43+
saveUninitialized: true,
44+
cookie: {
45+
secure: process.env.ENVIRONMENT === 'production' ? true : 'auto',
46+
maxAge: 24 * 60 * 60 * 1000,
47+
sameSite: 'lax',
48+
},
49+
})
50+
);
4051

4152
app.get('/api/healthcheck', (req: Request, res: Response) => res.sendStatus(200));
4253

@@ -58,13 +69,13 @@ const routes = async (app: Express) => {
5869

5970
app.use('/api/logout', (req: Request, res: Response) => {
6071
req.session.destroy((err) => {
61-
if (err) console.log('Error destroying session:', err)
72+
if (err) console.log('Error destroying session:', err);
6273
else {
63-
console.log('Succesfully destroyed session')
64-
return res.redirect(`${client_url}/`)
74+
console.log('Succesfully destroyed session');
75+
return res.redirect(`/`);
6576
}
6677
});
67-
})
78+
});
6879

6980
app.get('/*', (req, res) => {
7081
res.sendFile(path.join(__dirname, '../../dist/index.html'));
@@ -80,6 +91,6 @@ const routes = async (app: Express) => {
8091
const errorObj = Object.assign({}, defaultErr, err);
8192
return res.status(errorObj.status).json(errorObj.message);
8293
});
83-
}
94+
};
8495

85-
export default routes;
96+
export default routes;

src/components/DBDisplay/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const Sidebar = (props: any) => {
5656
//change between which getSchema from MySQL to postgres based on db_type
5757
const dbSchema = await axios
5858
.post(`api/sql/${values.db_type}/getSchema`, values, {
59-
baseURL: 'http://localhost:3000',
59+
baseURL: '/',
6060
})
6161
.then((res) => res.data)
6262
.catch((err) => console.log('getSchema error', err));

src/utils/getGoogleUrl.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
const getGoogleAuthUrl = () => {
2-
const base = 'https://accounts.google.com/o/oauth2/v2/auth';
2+
const base = 'https://accounts.google.com/o/oauth2/v2/auth';
33

4-
const options = {
5-
redirect_uri: 'http://localhost:3000/api/oauth/google',
6-
client_id: '373965291205-utb8ih1hoeuf1g90okil5ju43tfdl3vs.apps.googleusercontent.com',
7-
access_type: 'offline',
8-
response_type: 'code',
9-
prompt: 'consent',
10-
scope: [
11-
'https://www.googleapis.com/auth/userinfo.profile',
12-
'https://www.googleapis.com/auth/userinfo.email'
13-
].join(' ')
14-
}
15-
const queryStr = new URLSearchParams(options)
16-
return `${base}?${queryStr.toString()}`
17-
}
4+
const options = {
5+
redirect_uri: '/',
6+
client_id: '373965291205-utb8ih1hoeuf1g90okil5ju43tfdl3vs.apps.googleusercontent.com',
7+
access_type: 'offline',
8+
response_type: 'code',
9+
prompt: 'consent',
10+
scope: [
11+
'https://www.googleapis.com/auth/userinfo.profile',
12+
'https://www.googleapis.com/auth/userinfo.email',
13+
].join(' '),
14+
};
15+
const queryStr = new URLSearchParams(options);
16+
return `${base}?${queryStr.toString()}`;
17+
};
1818

1919
export const handleOAuthLogin = () => {
2020
const url = getGoogleAuthUrl();
21-
const strWindowFeatures = 'toolbar=no, menubar=no, width=600, height=700, top=100, left=100';
21+
const strWindowFeatures =
22+
'toolbar=no, menubar=no, width=600, height=700, top=100, left=100';
2223
window.open(url, '_self', strWindowFeatures);
23-
}
24+
};

0 commit comments

Comments
 (0)