https://github.com/mtlh/go-vercel-postgres
Instructions on how to create an api layer with Go, all hosted on vercel and connecting to a postgres database.
https://github.com/mtlh/go-vercel-postgres
Last synced: 3 months ago
JSON representation
Instructions on how to create an api layer with Go, all hosted on vercel and connecting to a postgres database.
- Host: GitHub
- URL: https://github.com/mtlh/go-vercel-postgres
- Owner: mtlh
- Created: 2024-04-24T19:49:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-08T04:06:00.000Z (about 1 year ago)
- Last Synced: 2025-01-03T04:46:20.523Z (5 months ago)
- Language: Go
- Homepage: https://go-vercel-postgres.vercel.app/api
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go + Vercel Functions + Postgres
Instructions on how to create an API layer with Go and common usage routes, all hosted on vercel and connecting to a postgres database.
## Routes
### /api
https://go-vercel-postgres.vercel.app/api
Index for application, holding basic application information.### /api/date
https://go-vercel-postgres.vercel.app/api/date
Get current date string.### /api/dbget
https://go-vercel-postgres.vercel.app/api/dbget
Connect to the postgres instance and retrieve id and name fields in the "USERS" table.### /api/dbdelete/id
https://go-vercel-postgres.vercel.app/api/dbdelete/1
Connect to the postgres instance and delete record using id variable in the "USERS" table.### /api/dbinsert/name
https://go-vercel-postgres.vercel.app/api/dbinsert/testingname
Connect to the postgres instance and insert record using name variable and incremented id, in the "USERS" table.### /api/dbupdate/id/name
https://go-vercel-postgres.vercel.app/api/1/updatedname
Connect to the postgres instance and update record using name and id variables, in the "USERS" table.## Getting Started
1. Clone the repo:
```sh
git clone https://github.com/mtlh/go-vercel-postgres.git
```2. Create .env file with the following fields:
```
PGHOST='hosturl'
PGDATABASE='db'
PGUSER='user'
PGPASSWORD='pass'
```3. Link to Vercel:
```
npm -g vercel
vercel --prod
```