This is a simple Node.js application using Express and PostgreSQL to provide CRUD functionality. The application has four routes for performing CRUD operations: register (POST), showall (GET), delete (DELETE), and update (PUT).
-
Clone the repository:
git clone <repository-url> cd test-backend
-
Running locally:
yarn yarn local
or
npm install npm run local
-
Runing on production:
yarn yarn prod
or
npm install npm run prod
-
Once the app is running locally, you can access the Node.js application at http://localhost:4000.
- POST /register: Register a new entry in the COMPANY table.
- GET /showall: Retrieve all entries from the COMPANY table.
- DELETE /delete: Delete an entry from the COMPANY table.
- PUT /update: Update an entry in the COMPANY table.
You can use tools like Postman or curl to test the API endpoints.
-
POST /register:
curl -X POST -H "Content-Type: application/json" -d '{"name":"John Doe","age":30,"address":"123 Main St","salary":50000,"join_date":"2024-01-24"}' http://localhost:4000/register
-
GET /showall:
curl http://localhost:4000/showall
-
DELETE /delete:
curl -X DELETE -H "Content-Type: application/json" -d '{"id":1}' http://localhost:4000/delete
-
PUT /update:
curl -X PUT -H "Content-Type: application/json" -d '{"first_name":"Updated","last_name":"User","email":"updated@example.com","mobile":"1234567890","id":1}' http://localhost:4000/update