Skip to content

Commit

Permalink
Merge pull request #66 from oslabs-beta/devops
Browse files Browse the repository at this point in the history
have deployed app serve correct files and configure URLs to use flakeguard.com
  • Loading branch information
willsuto authored Aug 12, 2024
2 parents d4b57dd + 8b8d12f commit c6c621b
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 13 deletions.
2 changes: 0 additions & 2 deletions flake-guard-app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ node_modules
.env
.DS_Store
build/
dist/*
coverage/
package-lock.json
dist/
3 changes: 2 additions & 1 deletion flake-guard-app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ WORKDIR /usr/src/app
COPY . /usr/src/app/

RUN npm install
RUN npm install -g ts-node
RUN npm run build

EXPOSE 3000

ENTRYPOINT ["node", "./src/server/buildServer.js"]
ENTRYPOINT ["ts-node", "./src/server/server.ts"]
2 changes: 1 addition & 1 deletion flake-guard-app/src/client/services/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';

export const api = axios.create({
baseURL: 'http://localhost:3000/',
baseURL: 'https://flakeguard.com/',
});
2 changes: 1 addition & 1 deletion flake-guard-app/src/client/tempDash/DecisionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const DecisionPage: React.FC = () => {
try {
const signInResponse = await supabaseClient.auth.signInWithOAuth({
provider: 'github',
options: {redirectTo: `http://localhost:8080/npm/${id}`},
options: {redirectTo: `https://flakeguard.com/npm/${id}`},
});
console.log('SIGN IN RESPONSE------>', signInResponse);
const {data, error} = await supabaseClient.auth.getUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('urlController', () => {
it('should generate a url and call next', () => {
res.locals.randomString = 'abcdefghij';
urlController.buildCustomUrl(req, res, next);
expect(res.locals.tempUrl).toBe('http://localhost:8080/npm/abcdefghij')
expect(res.locals.tempUrl).toBe('https://flakeguard.com/npm/abcdefghij')
expect(next).toHaveBeenCalled();
});
it('should call next with a CustomError on failure', () => {
Expand Down
2 changes: 1 addition & 1 deletion flake-guard-app/src/server/controllers/urlController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const urlController: UrlController = {

buildCustomUrl: (req: Request, res: Response, next: NextFunction) => {
try {
const tempUrl: string = `http://localhost:8080/npm/${res.locals.randomString}`;
const tempUrl: string = `https://flakeguard.com/npm/${res.locals.randomString}`;
res.locals.tempUrl = tempUrl;
next();
} catch (error) {
Expand Down
9 changes: 5 additions & 4 deletions flake-guard-app/src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ import resultsRouter from './routes/resultsRouter';
import userDashRouter from './routes/userDashRouter';
import tempDashRouter from './routes/tempDashRouter';
import {errorHandler} from './errors/errorHandler';
import {Request, Response} from 'express';

const app = express();
const PORT = process.env.PORT || 3000;

// Default middleware
app.use(bodyParser.json({limit: '10mb'}));
app.use(cors());
app.use(express.static(path.resolve(__dirname, '../client')));
app.use(express.static(path.resolve(__dirname, '../../dist')));

// Endpoints
app.use('/results', resultsRouter);
app.use('/tempDash', tempDashRouter);
app.use('/userDash', userDashRouter);

// 404 error handler
app.use((req, res) => {
res.status(404).send('Resource not found');
// Catch all
app.use('*', (req: Request, res: Response) => {
res.sendFile(path.resolve(__dirname, '../../dist/index.html'));
});

// Global error handler
Expand Down
3 changes: 2 additions & 1 deletion flake-guard-npm/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
.DS_Store
.DS_Store
node_modules
2 changes: 1 addition & 1 deletion flake-guard-npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const flakeGuard = async (iterations) => {
console.log(flakeGuardResults);
// Send results to Flake Guard App server
// const response = await fetch('https://2wguunmxpr.us-west-2.awsapprunner.com/results', {
const response = await fetch('http://localhost:3000/results', {
const response = await fetch('https://flakeguard.com/results', {
method: 'POST',
headers: {
'Content-Type': 'application/JSON',
Expand Down
16 changes: 16 additions & 0 deletions flake-guard-npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c6c621b

Please sign in to comment.