Instructions on how to create an API layer with Go and common usage routes, all hosted on vercel and connecting to a postgres database.
|
|
|
https://go-vercel-postgres.vercel.app/api
Index for application, holding basic application information.
https://go-vercel-postgres.vercel.app/api/date
Get current date string.
https://go-vercel-postgres.vercel.app/api/dbget
Connect to the postgres instance and retrieve id and name fields in the "USERS" table.
https://go-vercel-postgres.vercel.app/api/dbdelete/1
Connect to the postgres instance and delete record using id variable in the "USERS" table.
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.
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.
-
Clone the repo:
git clone https://github.com/mtlh/go-vercel-postgres.git
-
Create .env file with the following fields:
PGHOST='hosturl' PGDATABASE='db' PGUSER='user' PGPASSWORD='pass'
-
Link to Vercel:
npm -g vercel vercel --prod