Skip to content

Commit

Permalink
move backend into api dir
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardAndress committed Sep 2, 2022
1 parent 3667682 commit 6b5178f
Show file tree
Hide file tree
Showing 33 changed files with 10 additions and 10 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions controllers/posts.js → api/controllers/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Post = require("../models/post");
const TokenGenerator = require("../models/token_generator");

const PostsController = {
Index: (req, res, next) => {
Index: (req, res) => {
Post.find(async (err, posts) => {
if (err) {
throw err;
Expand All @@ -11,7 +11,7 @@ const PostsController = {
res.status(200).json({ posts: posts, token: token });
});
},
Create: (req, res, next) => {
Create: (req, res) => {
const post = new Post(req.body);
post.save(async (err) => {
if (err) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("/posts", () => {
});

test("creates a new post", async () => {
let response = await request(app)
await request(app)
.post("/posts")
.send({ message: "hello world", token: token });
let posts = await Post.find();
Expand All @@ -59,7 +59,7 @@ describe("/posts", () => {
});

test("a post is not created", async () => {
let response = await request(app)
await request(app)
.post("/posts")
.send({ message: "hello again world" });
let posts = await Post.find();
Expand All @@ -83,7 +83,7 @@ describe("/posts", () => {
let response = await request(app)
.get("/posts")
.send({token: token});
messages = response.body.posts.map((post) => ( post.message ));
let messages = response.body.posts.map((post) => ( post.message ));
expect(messages).toEqual(["howdy!", "hola!"]);
})

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ describe("/users", () => {
})

test("a user is created", async () => {
let response = await request(app)
await request(app)
.post("/users")
.send({email: "[email protected]", password: "1234"})
let users = await User.find()
newUser = users[users.length - 1]
let newUser = users[users.length - 1]
expect(newUser.email).toEqual("[email protected]")
})
})
Expand All @@ -35,7 +35,7 @@ describe("/users", () => {
});

test("does not create a user", async () => {
let response = await request(app)
await request(app)
.post("/users")
.send({email: "[email protected]"})
let users = await User.find()
Expand All @@ -52,7 +52,7 @@ describe("/users", () => {
});

test("does not create a user", async () => {
let response = await request(app)
await request(app)
.post("/users")
.send({password: "1234"})
let users = await User.find()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"scripts": {
"lint": "eslint .",
"start": "nodemon ./bin/www",
"start": "nodemon ./api/bin/www",
"start:test": "PORT=3030 MONGODB_URL='mongodb://0.0.0.0/acebook_test' npm start",
"test": "npm run lint && npm run test:unit && npm run test:integration",
"test:unit": "jest",
Expand Down

0 comments on commit 6b5178f

Please sign in to comment.