Skip to content

Commit

Permalink
Merge pull request #4 from Mcdavid95/ch-setup-express-server-167024078
Browse files Browse the repository at this point in the history
#167024078: Setup express server
  • Loading branch information
Mcdavid95 authored Jul 2, 2019
2 parents 0e1574c + c3d164a commit 85a426c
Show file tree
Hide file tree
Showing 5 changed files with 4,658 additions and 186 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": ["@babel/preset-env"],
// "plugins": [
// ["transform-runtime", {
// "polyfill": false,
// "regenerator": true
// }]
// ]
}
14 changes: 14 additions & 0 deletions helpers/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import bunyan from 'bunyan';

export const logger = () => {
const log = bunyan.createLogger({ name: 'myapp' });
return log;
};

export const handleServerError = (res, error) => {
logger().error(error);
return res.status(500).send({
status: 'error',
error: 'Internal Server Error'
});
};
22 changes: 22 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import express from 'express';
import helmet from 'helmet';
import cors from 'cors';
import morgan from 'morgan';
import { logger } from './helpers/utils';

const app = express();
// Log requests to the console.
app.use(morgan('dev'));

app.use(helmet())
.disable('x-powered-by')
.use(cors());
app.use(express.json());

app.get('/api/v1', (req, res) => res.status(200).send({
status: 'success',
message: 'Welcome Save A Seat API'
}));

app.listen(1337);
logger().info('app running on port ', 1337);
Loading

0 comments on commit 85a426c

Please sign in to comment.