Skip to content

Commit fc23b0a

Browse files
committed
Added pages and route template for react, google oauth libraries for backend
1 parent 16f3eef commit fc23b0a

File tree

13 files changed

+154
-33
lines changed

13 files changed

+154
-33
lines changed

backend/user-service/src/app.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Module } from '@nestjs/common';
22
import { AppController } from './app.controller';
33
import { AppService } from './app.service';
4+
import { AuthModule } from './auth/auth.module';
45

56
@Module({
6-
imports: [],
7+
imports: [AuthModule],
78
controllers: [AppController],
89
providers: [AppService],
910
})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Test, TestingModule } from '@nestjs/testing';
2+
import { AuthController } from './auth.controller';
3+
4+
describe('AuthController', () => {
5+
let controller: AuthController;
6+
7+
beforeEach(async () => {
8+
const module: TestingModule = await Test.createTestingModule({
9+
controllers: [AuthController],
10+
}).compile();
11+
12+
controller = module.get<AuthController>(AuthController);
13+
});
14+
15+
it('should be defined', () => {
16+
expect(controller).toBeDefined();
17+
});
18+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Controller, Get } from '@nestjs/common';
2+
3+
@Controller('auth')
4+
export class AuthController {
5+
@Get('google/login')
6+
googleLogin() {
7+
return {msg:"Login"}
8+
}
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Module } from '@nestjs/common';
2+
import { AuthController } from './auth.controller';
3+
4+
@Module({
5+
controllers: [AuthController]
6+
})
7+
export class AuthModule {}

backend/user-service/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AppModule } from './app.module';
33

44
async function bootstrap() {
55
const app = await NestFactory.create(AppModule);
6+
app.setGlobalPrefix('api')
67
await app.listen(3001);
78
}
89
bootstrap();

frontend/package-lock.json

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@react-oauth/google": "^0.12.1",
67
"@testing-library/jest-dom": "^5.17.0",
78
"@testing-library/react": "^13.4.0",
89
"@testing-library/user-event": "^13.5.0",
910
"react": "^18.3.1",
1011
"react-dom": "^18.3.1",
12+
"react-router-dom": "^6.26.2",
1113
"react-scripts": "5.0.1",
1214
"web-vitals": "^2.1.4"
1315
},
@@ -34,5 +36,8 @@
3436
"last 1 firefox version",
3537
"last 1 safari version"
3638
]
39+
},
40+
"devDependencies": {
41+
"tailwindcss": "^3.4.12"
3742
}
3843
}

frontend/src/App.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
import logo from './logo.svg';
2+
import { Route, Routes } from 'react-router-dom'
3+
import HomePage from './pages/HomePage'
24
import './App.css';
35

6+
47
function App() {
58
return (
6-
<div className="App">
7-
<header className="App-header">
8-
<img src={logo} className="App-logo" alt="logo" />
9-
<p>
10-
Edit <code>src/App.js</code> and save to reload.
11-
</p>
12-
<a
13-
className="App-link"
14-
href="https://reactjs.org"
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
>
18-
Learn React
19-
</a>
20-
</header>
21-
</div>
9+
<Routes>
10+
<Route path='/' element={<HomePage />}/>
11+
</Routes>
2212
);
2313
}
2414

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from "react";
2+
import { useGoogleLogin } from "@react-oauth/google";
3+
import { Link } from "react-router-dom";
4+
5+
const LoginButton = () => {
6+
const login = useGoogleLogin({
7+
onSuccess: codeResponse => console.log(codeResponse),
8+
flow: 'auth-code',
9+
});
10+
11+
return (
12+
<button onClick={() => login()}>Sign in with Google 🚀</button>
13+
);
14+
};
15+
16+
export default LoginButton;

frontend/src/index.css

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
body {
2-
margin: 0;
3-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5-
sans-serif;
6-
-webkit-font-smoothing: antialiased;
7-
-moz-osx-font-smoothing: grayscale;
8-
}
9-
10-
code {
11-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12-
monospace;
13-
}
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

0 commit comments

Comments
 (0)