You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In database.js the connections to the database with the Sequelize are defined
An instance of Express is initialized in app.js and its routes and middlewares are defined there (the routes point to the note controllers and users)
Sequelize models are synchronized with the database in index.js/main() and the server runs
React
The 'npm run start' is executed
The 'react-scripts start' utility is executed and this starts the development server
The 'App' component is called in index.js
The 'App' component handles the pagination and notes states, in order to pass the results to the 'NoteList' (where notes are listed and edited) and 'NoteAddForm' (where notes are added) components. It also handles the state of the user to be able to pass its result to the component 'LoginForm'
Comments/Improvements
I would add a more secure login method, as well as verify that the field meets some requirements
In larger projects, I would use migrations instead of sync(), because it can lead to data loss
I would improve the 'try & catch's to handle more specific cases and be able to return responses to the user more in line with the errors that arise
I would refactor image handling in note controllers to make it reusable
If we were using microservices, the media folder could go outside of client and server
On the React side, I would componentize most of the HTML, like the modal, the NavBar, etc.
Also in React, I would remove refreshes and use states to make it more dynamic
Requisites
Node JS v18.16.0
NPM v9.5.1
PostgreSQL 14.8
Installation
Clone the repository
Install server dependencies
cd server
npm install
Install client dependencies
cd client
npm install
Copy .envsample file and rename it to .env (/server and /client use different files)
Create a database in PostgreSQL and fill the variables in .env
Run server
cd server
npm run start
Run client
cd client
npm run start
API Documentation
Users
Login and Register
POST /login
Notes
Get all notes
GET /notes
Get a note
GET /notes/:id
Create a note
POST /notes
Update a note
PUT /notes/:id
Delete a note
DELETE /notes/:id
About
Simple project of a blog with notes made in Node + React