Skip to content

Commit

Permalink
Merge 31b3d2d into 0723eb2
Browse files Browse the repository at this point in the history
  • Loading branch information
UhiriweAudace committed Aug 6, 2019
2 parents 0723eb2 + 31b3d2d commit e99b974
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 254 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: NODE_ENV=staging yarn start
web: NODE_ENV=staging yarn start
2 changes: 1 addition & 1 deletion src/api/controllers/articlesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class articlesController {
const allArticle = await articles.getAllArticle();

if (!allArticle[0]) {
return res.status(404).send({ error: 'Whoops! No Articles found!' });
return res.status(200).send({ message: 'Whoops! No Articles found!' });
}
res.status(200).send({
articles: allArticle
Expand Down
7 changes: 7 additions & 0 deletions src/middleware/globalMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ export default (app) => {
.use(bodyParser.urlencoded({ extended: true }))
// Allow cross origin requests
.use(cors());
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, OPTIONS, POST, PUT, PATCH, DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, token');
res.header('Access-Control-Allow-Credentials', true);
return next();
});
if (process.env.NODE_ENV !== 'test') {
app.use(morgan('dev'));
}
Expand Down
Loading

0 comments on commit e99b974

Please sign in to comment.