1. go run . serve // to run the app/server
2. go run . migrate -u // for database migration
go run . migrate -d // for database rollback
3. go run . seed // to seeding data Role admin if you want :
email : "admin@gmail.com"
password : admin123456781๏ธโฃ Make root folder in your Gopath
github.com/Lectron-Fazztrack2๏ธโฃ Chosee project name "Final-Project"
3๏ธโฃ Clone the repository inside the folder that was created "github.com/Lectron-Fazztrack"
git clone https://github.com/Lectron-Fazztrack/Final-Project.git4๏ธโฃ Intstall dependencies
go mod tidy5๏ธโฃ Add Env
DBHOST = DB Host
DBUSER = DB User
DBPASS = DB Password
DBNAME = DB Name
JWT_KEYS = JWT Keys
DBSSL = DB SSL
CLOUD_NAME = Cloud Name
CLOUD_KEY = API Key
CLOUD_SEC = API Secret6๏ธโฃ Database Migration and Rollback
go run . migrate --up // database migrate table
go run . migrate --down //rollback the database7๏ธโฃ Seeding data admin
go run . seedโก๏ธ PURPOSE TO LOGIN AS ADMIN'S ROLE { "email" : "admin@gmail.com", "password" : "admin12345678" }
8๏ธโฃ Run the app
go run . serve==================================================
route.POST("/register", ctrl.Register)
๐ง Create new Admin :
{
"name": "<your name>",
"email": "<your email>",
"role": "<admin>",
"password": "<your password>",
"addres": "<your address>",
"phone": "<your phone number>",
"gender": "<male/female>"
}โ๏ธ Respond :
{
"status": "OK",
"isError": false,
"data": {
"id": "<uuid>",
"name": "<name>",
"email": "<email>",
"role": "<admin>",
"Password": "<generate password>",
"gender": "<male/female>",
"date": "<date>",
"created_at": "<created time>",
"updated_at": "<updated time>"
}
}
๐ง Create new User :
{
"name": "<your name>",
"email": "<your email>",
"password": "<your password>",
"addres": "<your address>",
"phone": "<your phone number>",
"gender": "<male/female>"
}
โ๏ธ Respond :
{
"status": "OK",
"isError": false,
"data": {
"id": "<uuid>",
"name": "<name>",
"email": "<email>",
"role": "<user>",
"Password": "<generate password>",
"gender": "<male/female>",
"date": "<date>",
"created_at": "<created time>",
"updated_at": "<update time>"
}
}โ๏ธ Request Body :
{
"name": "<your name>", (STRING)
"email": "<your email>", (STRING)
"role": "<admin>", (STRING)
"password": "<your password>", (STRING)
"addres": "<your address>", (STRING)
"phone": "<your phone number>", (INT)
"gender": "<male/female>" (STRING)
}
==================================================
route.POST("/login", ctrl.Login)
๐ง Proses Login
{
"email" : "<your email>",
"password" : "<your password>"
}โ๏ธ Respond :
{
"status": "OK",
"isError": false,
"data": {
"token": "<your token>"
}
}โ๏ธ Request Body :
{
"email" : <your email> (STRING),
"password" : <your password> (STRING)
}==================================================
โ Add Product
route.POST("", middleware.CheckAuth(), middleware.CheckAuthor(), middleware.Cloudinary(), ctrl.AddProduct)โพ๏ธ Update Product
route.PUT("/:id", middleware.CheckAuth(), middleware.CheckAuthor(), middleware.Cloudinary(), ctrl.UpdateProduct)โ Delete Product
route.DELETE("/:id", middleware.CheckAuth(), middleware.CheckAuthor(), ctrl.DeleteProduct)ยฎ๏ธ Get All
route.GET("", ctrl.GetAllProduct)ยฎ๏ธ Get By Id
route.GET("/:id", ctrl.GetById)ยฎ๏ธ Get By Type
route.GET("/types/:type", ctrl.GetByType)โ๏ธ Request Body :
{
"name" : "<product name>", (STRING)
"image" : "<product image>", (STRING)
"stock" : "<product stock>", (STRING)
"telphone" : "<your password>", (INT)
"price" : "<product price>", (INT)
"type" : "<product type>", (INT)
"sold" : "<product sold>" (STRING),
"description" : "<description product>" (STRING)
}
==================================================
โ๏ธ Request Body :
{
"product_id" : "<rate>", (INT)
"amount" : "<comment>" (INT)
}==================================================
๐ route.POST("/checkout", ctrl.Checkout)
๐ route.GET("/histories", ctrl.Histories)
โ๏ธ Request Body :
{
"checkout_name" : "<checkout name>", (STRING)
"product_id" : "<product id>", (INT)
"deliv_address" : "<delivery address>", (STRING)
"telphone" : "<your password>", (INT)
"notes" : "<notes>", (STRING)
"discount" : "<product discount>", (INT)
"amount" : "<amount>", (INT)
"total" : "<total>", (INT)
"status" : "<status product>", (STRING)
"payment" : "<payment>" (STRING)
}
==================================================
โ Add Review
route.POST("/review", middleware.CheckAuth(), ctrl.PostReview)ยฎ๏ธ Get By Type
route.GET("/review/:id", ctrl.GetReview)โ๏ธ Request Body :
{
"rate" : "<rate>", (INT)
"comment" : "<comment>" (STRING)
}
==================================================
==================================================
โ Deployment on heroku
heroku container:login
heroku create <app-backend-name>
heroku create <app-frontend-name>
heroku git:remote -a <app-backend-name>
heroku git:remote -a <app-frontend-name>
heroku container:push backend --app <app-backend-name>
heroku container:release backend --app <app-backend-name>
heroku container:push frontend --app <app-frontend-name>
heroku container:release frontend --app <app-frontend-name>==================================================
