Skip to content

Commit

Permalink
first commit; initial setup minor changes to server to prep development
Browse files Browse the repository at this point in the history
  • Loading branch information
sfryan95 committed Apr 19, 2024
1 parent 1b91777 commit e4e6446
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Redeployment should also be done with only the server subtree and not the entire

If `npm` is your package manager, you just need to run the script `npm run dev` and it will start the server on `http://localhost:${DEV_PORT}` for your development environment.
DEV_PORT can be defined in the config.js file on the root directory.
You will also need to define your server address(MONGO_DB_DEV), github OAuth ID (GITHUB_ID) & Secret (GITHUB_SECRET) in a dotenv file in the root directory as well.
You will also need to define your server address(MONGO_DB_DEV), github OAuth ID (GITHUB_CLIENT) & Secret (GITHUB_SECRET) in a dotenv file in the root directory as well.

Endpoint testing is currently integrated with Jest and Supertest as well and can be run by `npm run test` or `npm run test:watch` for watch mode.
6 changes: 3 additions & 3 deletions server/routers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface UserReq extends Request {
};
}

const { API_BASE_URL } = config;
const { API_BASE_URL2 } = config;
const router = express.Router();

router.get(
Expand Down Expand Up @@ -41,7 +41,7 @@ router.get(
sameSite: 'none',
secure: true
});
return res.redirect(API_BASE_URL);
return res.redirect(API_BASE_URL2);
}
);

Expand Down Expand Up @@ -69,7 +69,7 @@ router.get(
sameSite: 'none',
secure: true
});
return res.redirect(API_BASE_URL);
return res.redirect(API_BASE_URL2);
}
);

Expand Down
8 changes: 8 additions & 0 deletions server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import dotenv from 'dotenv';
dotenv.config();

const app = express();
console.log('process.env.NODE_ENV check', process.env.NODE_ENV);

const PORT = process.env.PORT || DEV_PORT;
const isDev = process.env.NODE_ENV === 'development';
Expand All @@ -49,6 +50,13 @@ app.use(
})
);

function logRequest(req, res, next) {
const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`;
console.log(`Received request on ${req.method}: ${fullUrl}`);
next();
}
app.use(logRequest);

//if in production mode, statically serve everything in the build folder on the route '/dist'
if (process.env.NODE_ENV == 'production') {
console.log('currently in port', process.env.PORT);
Expand Down

0 comments on commit e4e6446

Please sign in to comment.