Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mike Smith #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Empty file added controllers/notes.js
Empty file.
Empty file added controllers/users.js
Empty file.
22 changes: 22 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
const express = require("express");
const parser = require("body-parser");
const cors = require("cors");
const bookmarksController = require("./controllers/notes");
const usersController = require("./controllers/users");

const app = express();

app.use(parser.urlencoded({ extended: true }));

app.use(parser.json());

app.use(cors());

app.get("/", (req, res) => {
res.redirect("/api/users");
});

app.use("/api/users/", bookmarksController);

app.use("/api/notes/", usersController);

app.listen(3000, () => console.log('app is running'))

// DO NOT REMOVE THIS LINE:
Expand Down
15 changes: 15 additions & 0 deletions models/Note.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,18 @@ const mongoose = require('../db/connection')
const noteSchema = new mongoose.Schema({})

module.exports = mongoose.model('Note', noteSchema)

const noteSchema = mongoose.Schema({
title: String,
body: String,
author: [
{
ref: "User",
type: mongoose.Schema.Types.ObjectId
}
]
});

const User = mongoose.model("Note", UserSchema);

module.exports = Note;
15 changes: 15 additions & 0 deletions models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,18 @@ const mongoose = require('../db/connection')
const userSchema = new mongoose.Schema({})

module.exports = mongoose.model('User', userSchema)

const userSchema = mongoose.Schema({
username: String,
email: String,
notes: [
{
ref: "User",
type: mongoose.Schema.Types.ObjectId
}
]
});

const User = mongoose.model("User", UserSchema);

module.exports = User;
Loading