Skip to content

refactor files and folder - SRP.#1

Open
rogergcc wants to merge 1 commit intobradtraversy:masterfrom
rogergcc:master
Open

refactor files and folder - SRP.#1
rogergcc wants to merge 1 commit intobradtraversy:masterfrom
rogergcc:master

Conversation

@rogergcc
Copy link
Copy Markdown

server.js
create app.js
and app folder
Single responsibility principle

Single responsibility principle
Comment thread app/app.js
const Server = http.createServer((req, res) => {
if(req.url === '/api/products' && req.method === 'GET') {
getProducts(req, res)
} else if(req.url.match(/\/api\/products\/([0-9]+)/) && req.method === 'GET') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OK

@@ -1,7 +1,7 @@
let products = require('../data/products')
const { v4: uuidv4 } = require('uuid')

const { writeDataToFile } = require('../utils')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OK

Comment thread server.js
const { getProducts, getProduct, createProduct, updateProduct, deleteProduct } = require('./app/controllers/productController')
const Server= require('./app/app')


Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OK

Comment thread server.js



server.listen(PORT, () => console.log(`Server running on port ${PORT}`)) No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants