Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/CA-G12/BMS into 44-review-t…
Browse files Browse the repository at this point in the history
…ransactions-users
  • Loading branch information
mohjaps committed Oct 13, 2022
2 parents 996e61c + 008eaf5 commit b2551d3
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 10 deletions.
113 changes: 113 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"express": "^4.17.3",
"joi": "^17.6.3",
"jsonwebtoken": "^8.5.1",
"morgan": "^1.10.0",
"pg": "^8.8.0",
"pg-hstore": "^2.3.4",
"sequelize": "^6.25.0",
Expand All @@ -47,6 +48,7 @@
"@types/express": "^4.17.13",
"@types/jest": "^27.4.1",
"@types/jsonwebtoken": "^8.5.8",
"@types/morgan": "^1.9.3",
"@types/node": "^17.0.25",
"@types/nodemailer": "^6.4.4",
"@types/pg": "^8.6.5",
Expand Down
26 changes: 19 additions & 7 deletions server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,35 @@ import express from 'express';
import compression from 'compression';
import dotenv from 'dotenv';
import cookieParser from 'cookie-parser';
// import router from './routes';
import { join } from 'path';
import morgan from 'morgan';

dotenv.config();

const app = express();

const {
env: { PORT, NODE_ENV },
} = process;

dotenv.config();
app.set('port', PORT || 5000);

app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(compression());
app.use(cookieParser());

app.use('/', (req, res) => {
res.send('hello bms');
});
if (NODE_ENV === 'development') {
app.use(morgan('dev'));
}

// app.use('/api/v1', router);

if (NODE_ENV === 'production') {
app.use(express.static(join(__dirname, '..', 'client', 'build')));
app.get('*', (req, res) => {
res.sendFile(join(__dirname, '..', 'client', 'build', 'index.html'));
});
}

app.set('port', PORT || 5000);

export default app;
12 changes: 9 additions & 3 deletions server/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import app from './app';
import sequelize from './database/config/connection';

const port = app.get('port') as number;

app.listen(port, () => {
sequelize.sync({ force: true }) // TODO: To be reomved later when DB is 100% ready
.then(() => {
app.listen(port, () => {
// eslint-disable-next-line no-console
console.log(`The Server is running on http://localhost:${port}`);
});
})
// eslint-disable-next-line no-console
console.log(`http://localhost:${port}`);
});
.catch(() => console.log('Error on synchronizing db'));

0 comments on commit b2551d3

Please sign in to comment.