Skip to content

Commit

Permalink
Restructured project to make server-client cleaner; Linked back-front…
Browse files Browse the repository at this point in the history
… ends with mongo; other various config updates
  • Loading branch information
l3zero committed Apr 15, 2020
1 parent 008fca5 commit 8f89db5
Show file tree
Hide file tree
Showing 46 changed files with 16,237 additions and 15,136 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ yarn-error.log*
# production
/build
/node_modules
client/node_modules
15,269 changes: 15,269 additions & 0 deletions client/package-lock.json

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "slide-news",
"version": "0.1.0",
"private": true,
"engines": {
"npm": ">=6.10.0",
"node": ">=10.13.0"
},
"dependencies": {
"@hapi/joi": "^17.1.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"moment": "^2.24.0",
"node-cache": "^5.1.0",
"node-fetch": "^2.6.0",
"object-hash": "^2.0.3",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"postBuild": "mv build ./server/",
"test": "react-scripts test",
"eject": "react-scripts eject",
"scss": "node-sass --watch src/scss -o src/styles"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^2.4.0",
"eslint-plugin-security": "^1.4.0",
"mongoose": "^5.9.3",
"node-sass": "^4.13.1",
"prettier": "^1.19.1"
},
"proxy": "http://localhost:9000"
}
4 changes: 2 additions & 2 deletions public/index.html → client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="icon" href="%PUBLIC_URL%/sun.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="sun192.png" />
<!--<link rel="apple-touch-icon" href="sun192.png" />-->
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand Down Expand Up @@ -40,4 +40,4 @@
-->
</body>

</html>
</html>
8 changes: 8 additions & 0 deletions client/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"short_name": "Slide News",
"name": "Slide News",
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Binary file added client/public/sun.ico
Binary file not shown.
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.
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.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const NewsCollection = require('../model/newsMongoCollection.js')

uploadNews = (req, res) => {
const uploadNews = (req, res) => {
const body = req.body

if (!body) {
Expand All @@ -22,7 +22,7 @@ uploadNews = (req, res) => {
return res.status(201).json({
success: true,
id: newsObject._id,
message: 'News object created!',
message: 'News object created!'
})
})
.catch(error => {
Expand All @@ -33,8 +33,8 @@ uploadNews = (req, res) => {
})
}

getNews = async (req, res) => {
await NewsCollection.findOne({ _id: req.params.id }, (err, news) => {
const getNews = async (req, res) => {
await NewsCollection.findOne({ newsId: req.params.id }, (err, news) => {
if (err) {
return res.status(400).json({ success: false, error: err })
}
Expand All @@ -48,7 +48,7 @@ getNews = async (req, res) => {
}).catch(err => console.log(err))
}

/*getAllNews = async (req, res) => {
const getAllNews = async (req, res) => {
await NewsCollection.find({}, (err, news) => {
if (err) {
return res.status(400).json({ success: false, error: err })
Expand All @@ -60,7 +60,7 @@ getNews = async (req, res) => {
}
return res.status(200).json({ success: true, data: news })
}).catch(err => console.log(err))
}*/
}

/*deleteNews = async (req, res) => {
await NewsCollection.findOneAndDelete({ _id: req.params.id }, (err, news) => {
Expand All @@ -80,5 +80,6 @@ getNews = async (req, res) => {

module.exports = {
uploadNews,
getNews
getNews,
getAllNews
}
2 changes: 1 addition & 1 deletion server/db/mongoDB.js → db/mongoDB.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import mongoose from 'mongoose'
const mongoose = require('mongoose')
mongoose.set('autoIndex', false)
//mongoose.set('autoIndex', false)
// mongoose.set('bufferCommands', false)
// mongoose.set('autoCreate', false)
const userName = process.env['MONGODB_USER']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const mongoose = require('mongoose')
const Schema = mongoose.Schema

const NewsCollection = new Schema({
id: String,
newsId: String,
created: Date,
expiration: Date,
articles: [{title: String, url: String, imageUrl: String}]
})

module.exports = mongoose.model('newsDump', NewsCollection)
module.exports = mongoose.model('newsdumps', NewsCollection)
Loading

0 comments on commit 8f89db5

Please sign in to comment.