aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--part4/blog/src/index.js47
-rw-r--r--part4/blog/src/index.js.bak8
2 files changed, 0 insertions, 55 deletions
diff --git a/part4/blog/src/index.js b/part4/blog/src/index.js
deleted file mode 100644
index f9dbf0d..0000000
--- a/part4/blog/src/index.js
+++ /dev/null
@@ -1,47 +0,0 @@
-const express = require('express')
-const app = express()
-const cors = require('cors')
-const mongoose = require('mongoose')
-
-const blogSchema = new mongoose.Schema({
- title: String,
- author: String,
- url: String,
- likes: Number
-})
-
-const Blog = mongoose.model('Blog', blogSchema)
-
-console.log("Connecting to mongo server")
-const mongoUrl = 'mongodb+srv://imkusa:<Password>@cluster0.aookaoo.mongodb.net/?retryWrites=true&w=majority'
-mongoose.connect(mongoUrl)
-console.log("Successfully connected to mongo server")
-
-app.use(cors())
-app.use(express.json())
-
-app.get('/api/blogs', (request, response) => {
- Blog
- .find({})
- .then(blogs => {
- response.json(blogs)
- })
- .catch((error) => {
- console.log(error.message)
- })
-})
-
-app.post('/api/blogs', (request, response) => {
- const blog = new Blog(request.body)
-
- blog
- .save()
- .then(result => {
- response.status(201).json(result)
- })
-})
-
-const PORT = 3003
-app.listen(PORT, () => {
- console.log(`Server running on port ${PORT}`)
-})
diff --git a/part4/blog/src/index.js.bak b/part4/blog/src/index.js.bak
deleted file mode 100644
index 8b1c250..0000000
--- a/part4/blog/src/index.js.bak
+++ /dev/null
@@ -1,8 +0,0 @@
-import React from 'react';
-import ReactDOM from 'react-dom/client';
-import App from './App';
-
-const root = ReactDOM.createRoot(document.getElementById('root'));
-root.render(
- <App />
-);