diff --git a/flake-guard-app/.gitignore b/flake-guard-app/.gitignore index cec19d1..5c8e9ce 100644 --- a/flake-guard-app/.gitignore +++ b/flake-guard-app/.gitignore @@ -2,7 +2,5 @@ node_modules .env .DS_Store build/ -dist/* coverage/ -package-lock.json dist/ \ No newline at end of file diff --git a/flake-guard-app/Dockerfile b/flake-guard-app/Dockerfile index 92ae4d5..d7109f2 100644 --- a/flake-guard-app/Dockerfile +++ b/flake-guard-app/Dockerfile @@ -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"] diff --git a/flake-guard-app/src/client/services/index.tsx b/flake-guard-app/src/client/services/index.tsx index 711cceb..9bf542f 100644 --- a/flake-guard-app/src/client/services/index.tsx +++ b/flake-guard-app/src/client/services/index.tsx @@ -1,5 +1,5 @@ import axios from 'axios'; export const api = axios.create({ - baseURL: 'http://localhost:3000/', + baseURL: 'https://flakeguard.com/', }); diff --git a/flake-guard-app/src/client/tempDash/DecisionPage.tsx b/flake-guard-app/src/client/tempDash/DecisionPage.tsx index 1fa67fa..dd77872 100644 --- a/flake-guard-app/src/client/tempDash/DecisionPage.tsx +++ b/flake-guard-app/src/client/tempDash/DecisionPage.tsx @@ -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(); diff --git a/flake-guard-app/src/server/controllers/urlController.test.js b/flake-guard-app/src/server/controllers/urlController.test.js index 4e78f0e..8164939 100644 --- a/flake-guard-app/src/server/controllers/urlController.test.js +++ b/flake-guard-app/src/server/controllers/urlController.test.js @@ -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', () => { diff --git a/flake-guard-app/src/server/controllers/urlController.ts b/flake-guard-app/src/server/controllers/urlController.ts index 329a84d..4c68b3d 100644 --- a/flake-guard-app/src/server/controllers/urlController.ts +++ b/flake-guard-app/src/server/controllers/urlController.ts @@ -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) { diff --git a/flake-guard-app/src/server/server.ts b/flake-guard-app/src/server/server.ts index 63abd8c..a27b40b 100644 --- a/flake-guard-app/src/server/server.ts +++ b/flake-guard-app/src/server/server.ts @@ -7,6 +7,7 @@ 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; @@ -14,16 +15,16 @@ 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 diff --git a/flake-guard-npm/.gitignore b/flake-guard-npm/.gitignore index 4c842e4..89657c0 100644 --- a/flake-guard-npm/.gitignore +++ b/flake-guard-npm/.gitignore @@ -1,2 +1,3 @@ .env -.DS_Store \ No newline at end of file +.DS_Store +node_modules \ No newline at end of file diff --git a/flake-guard-npm/index.js b/flake-guard-npm/index.js index d6184b7..904a53e 100755 --- a/flake-guard-npm/index.js +++ b/flake-guard-npm/index.js @@ -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', diff --git a/flake-guard-npm/package-lock.json b/flake-guard-npm/package-lock.json new file mode 100644 index 0000000..3c1ea45 --- /dev/null +++ b/flake-guard-npm/package-lock.json @@ -0,0 +1,16 @@ +{ + "name": "flake-guard", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "flake-guard", + "version": "1.0.0", + "license": "ISC", + "bin": { + "flake-guard": "index.js" + } + } + } +}