https://github.com/eljandoubi/crm-backend
Simple CRM backend written in Go
https://github.com/eljandoubi/crm-backend
backend docker golang postgresql restful-api static-site
Last synced: about 2 months ago
JSON representation
Simple CRM backend written in Go
- Host: GitHub
- URL: https://github.com/eljandoubi/crm-backend
- Owner: eljandoubi
- License: apache-2.0
- Created: 2024-03-01T19:17:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-02T12:37:57.000Z (about 1 year ago)
- Last Synced: 2025-01-24T22:35:34.821Z (3 months ago)
- Topics: backend, docker, golang, postgresql, restful-api, static-site
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CRM-Backend
A simple CRM backend written in Go.
## Set up PostgreSQL via Docker
```bash
docker run --name my_postgres -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres
```Wait a couple of minutes for PostgreSQL to start, and then run the following commands:
```bash
docker exec -it my_postgres psql -U userCREATE DATABASE db_customers;
\q
```## Set up the Environment
Clone the repository in your `GOPATH`:
```bash
go env GOPATH
cd {put your GOPATH here}/src
git clone https://github.com/eljandoubi/CRM-Backend.git
cd CRM-Backend
```Then set up packages and start the server:
```bash
go mod init
go get github.com/lib/pq
go get github.com/gorilla/mux
go run main.go
```## Test the API
List all customers:
```bash
curl -is http://localhost:3000/customers
```Add a customer:
```bash
curl -is -X POST -H "Content-Type: application/json" -d '{"ID":4,"Name": "eljandoubi", "Role": "Data Scientist", "Email": "[email protected]", "Phone": "123456789", "Contacted": true}' http://localhost:3000/customers
```Update a customer:
```bash
curl -is -X PUT -H "Content-Type: application/json" -d '{"Name": "eljandoubi", "Role": "Data Scientist", "Email": "[email protected]", "Phone": "123456789", "Contacted": false}' http://localhost:3000/customers/4
```Get a customer:
```bash
curl -is http://localhost:3000/customers/4
```Delete a customer:
```bash
curl -is -X DELETE http://localhost:3000/customers/4
```