Basic text search in PostgreSQL with LIKE operator and method to avoid SQL injection on simple React frontend
Table of Contents
More of a personal repo - an exercise to learn about SQL injection attacks and interacting between React and PostgreSQL with minimal backend (I usually would throw Django in here)
Obviously this template was built with PostgreSQL and React. Most React code through create-react-app
. Here's links to Django and React:
Just a simple search. The React frontend is pretty much vanilla, and the pg-database is simple.
For this template to work you need to have nodejs and postgresql installed. Just download install both and then:
Update node to the most recent version:
npm install npm@latest -g
- Clone the repo and make it your current working directory
then
git clone https://github.com/repo.git
cd repo
-
You may have to install react-scripts. Do this by
npm i -g react-scripts
-
Create database in PostgreSQL - use the database.sql commands once in psql CLI. Create database partydb, create table users, and insert all users. Copy and paste from document. You can double-check you have 500 users with:
SELECT COUNT(*) FROM users;
-
For frontend and backend, get/install all packages for each (while in their directory):
yarn
or
npm install
-
Run backend with:
node index
-
Run frontend with:
yarn start
or
npm start
To edit the React frontend, see the README.md in /frontend directory
Show a more fleshed out example of using this template using data more than just names.
Let me know of any issues - See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Definitely check out the PostgreSQL and React documentation for tutorials and questions.