Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions server/src/api/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const express = require('express');

const { users } = require('./users');
const { posts } = require('./posts');

const api = express.Router();

api.use('/users', users);
api.use('/posts', posts);

module.exports.api = api;
18 changes: 18 additions & 0 deletions server/src/api/posts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const express = require('express');

const Posts = require('../../db/Posts');

const posts = express.Router();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you rename this to

Suggested change
const posts = express.Router();
const postsRouter = express.Router();


posts.get('/', (req, res) => {
Posts.findAll()
.then((posts) => {
res.send(posts);
})
.catch((err) => {
console.error(err);
res.sendStatus(500);
});
});

module.exports.posts = posts;