Skip to content

gocroot/gocroot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang template for CI/CD in alwaysdata.com

This is a simple Golang template using Go Fibre as the base framework, and mongodb.com as database host. It is compatible with alwaysdata.com CI/CD deployment. Inside the folder .github/workflows, you might choose your cloud provider and remove the .template extension :

  1. fly.io: fly.yml
  2. alwaysdata.com: alwaysdata.yml

MongoDB Preparation

The first thing to do is prepare a Mongo database using this template:

  1. Sign up for mongodb.com and create one instance of Data Services of mongodb.
  2. Download MongoDB Compass, connect with your mongo string URI from mongodb.com
  3. Create database name iteung and collection reply
    image
  4. Import this json into reply collection.
    image
    image
    image

Go Boilerplate Folder Structure

image

This boilerplate has several folders with different functions, such as:

  • .github: GitHub Action yml configuration.
  • URL: same as routes, this folder acts to route URL in the browser into the controller
  • config: all apps configuration like database, API, token.
  • controller: all of the endpoint functions
  • model: all of the type structs used in this app
  • helper: package folder with function only called by others

Alwaysdata.com CI/CD set

image

Sign Up for a 100MB plan Free for life in alwaysdata. Login into your dashboard and follow this instruction:

  1. Open the menu Web>Sites>Modify image
  2. In the Configuration section edit command and Environment image
    Please set the environment variable in your system:
    MONGOSTRING=YOURMONGOSTRINGACCESS
    WAQRKEYWORD=yourkeyword
    WEBHOOKURL=https://yourappname.alwaysdata.net/whatsauth/webhook
    WEBHOOKSECRET=yoursecret
    WAPHONENUMBER=62811111
    In this menu, you will see an APPID in the title, shown as a number and a home folder used in the github secrets variable.
  3. Go to menu REmote Access>SSH>Modify, set a very strong password and tick enable password-based login
  4. Set APIKEY in Customer Area>Profile >Managing Tokens>Generate a token
  5. Add sshhost, sshusername, sshpassword, sshport, apikey, appid and folder in your GitHub secret>action variable image

WhatsAuth Signup

  1. Go to the WhatsAuth signup page and scan with your WhatsApp camera menu for login.

  2. Input the webhook URL(https://yourappname.alwaysdata.net/whatsauth/webhook) and your secret from the WEBHOOKSECRET setting environment on Always Data.
    image

  3. Follow this instruction, in the end of instruction you will get 30 days token using this request

  4. Save the token into MongoDB, open iteung db, create a profile collection and insert this JSON document with your 30-day token and your WhatsApp number. image
    image

    {
      "token":"v4.public.asoiduas",
      "phonenumber":"6281111"
    }

    image

Refresh Whatsapp API Token

To continue using WhatsAuth service, we must get new token every 3 week before token expired in 30 days.

  1. Open Menu Scheduled tasks> Add scheduled task
    image
  2. Select Access to URLs, fill in the value with https://yourappname.alwaysdata.net/whatsauth/refreshtoken also your email address.
    image
  3. Set Frequency every 3 weeks image

Upgrade Apps

If you want to upgrade apps, please delete (go.mod) and (go.sum) files first, then type the command in your terminal or cmd :

go mod init gocroot
go mod tidy

About

boilerplate for using aiteung package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%