{"id":13827362,"url":"https://github.com/lnquy/less","last_synced_at":"2025-12-28T19:13:15.944Z","repository":{"id":57531427,"uuid":"106159072","full_name":"lnquy/less","owner":"lnquy","description":"Go serverless website on AWS Lambda.","archived":false,"fork":false,"pushed_at":"2017-10-11T14:34:26.000Z","size":1211,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-04T09:06:40.194Z","etag":null,"topics":["apex","aws-lambda","aws-s3","dynamodb","go","golang","serverless","vuejs"],"latest_commit_sha":null,"homepage":"https://lnquy.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lnquy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-08T07:50:38.000Z","updated_at":"2020-07-05T20:03:09.000Z","dependencies_parsed_at":"2022-09-06T17:22:00.463Z","dependency_job_id":null,"html_url":"https://github.com/lnquy/less","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnquy%2Fless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnquy%2Fless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnquy%2Fless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnquy%2Fless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lnquy","download_url":"https://codeload.github.com/lnquy/less/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225481528,"owners_count":17481175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apex","aws-lambda","aws-s3","dynamodb","go","golang","serverless","vuejs"],"created_at":"2024-08-04T09:01:54.629Z","updated_at":"2025-10-14T12:10:09.166Z","avatar_url":"https://github.com/lnquy.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# less\nSimple Go serverless website on Amazon Web Services (AWS).   \nDemo: [https://6epko5iya8.execute-api.ap-southeast-1.amazonaws.com/dev](https://6epko5iya8.execute-api.ap-southeast-1.amazonaws.com/dev).  \n\nWebsite's frontend is written in `VueJS`, which stored on a public `AWS S3` bucket.  \nThere're two simple `AWS Lambdas` written in Go (deployed via `apex` with NodeJS shim runtime):\n\n- `less_crawler`: Crawls [Github trending](https://github.com/trending) repositories, parses and persists data to `DynamoDB`. This function is triggered by a `CloudWatch` cron job.\n- `less_caterer`: Receives HTTP request from client and lookup on `DynamoDB` for trending repositories by day.\n\n`API Gateway` serves two APIs, one to GET the `index.html` page on S3 bucket (forward/proxy request to the URL of `index.html` file on S3). The other allows client to lookup Gihub trending repositories by day (which calling the `less_caterer` lambda).\n\n## Architecture\n\nThis repo contains the code for `Lambda` and `S3` parts in the image below.  \n![Architecture](https://github.com/lnquy/less/blob/master/images/less-arch.jpg)\n\n## Deploy on AWS\n\n#### Local development\n\nYou have to install [Go SDK](https://golang.org/dl/), [glide](https://github.com/Masterminds/glide), [AWS CLI](http://docs.aws.amazon.com/cli/latest/userguide/installing.html), [apex](http://apex.run/) and [configure the AWS credential](http://apex.run/#aws-credentials) to deploy your functions on AWS Lambda.  \n\n- Clone the repository to your local `$GOPATH` and install Go dependencies:\n\n  ```shell\n  $ go get github.com/lnquy/less\n  $ cd $GOPATH/src/github.com/lnquy/less\n  $ glide install\n  ```\n\n- The AWS region is `ap-southeast-1`, you have to take a look on the `functions` code and change the `awsRegion` value to deploy on another region.\n\n#### Lambdas\n\n- Create a role for the Lambdas on AWS IAM which have access to `DynamoDB` service.\n\n- Change the role to match your IAM Lambda role: [project.json#L4](https://github.com/lnquy/less/blob/master/project.json#L4).\n\n- Deploy to AWS:\n\n  ```shell\n  $ apex deploy  \n  ```\n\n#### Frontend and S3\n\n- Create a public S3 bucket for static web hosting, get the URL of the bucket.\n\n- Change the `publicPath` to your S3 bucket URL: [webpack.config.js#L6](https://github.com/lnquy/less/blob/master/frontend/webpack.config.js#L6)\n\n- Change the `GetCaterer` to your `POST /api/v1/trending/` API URL: [main.js#L22](https://github.com/lnquy/less/blob/master/frontend/src/main.js#L22)\n\n- Build frontend:\n\n  ```\n  $ cd frontend\n  $ npm install   // or yarn\n  $ npm run build\n  ```\n\n- Upload all `frontend/dist` files to the root of S3 bucket, make sure all files has public read permission.\n\n- Note the HTTP URL to the `index.html` file.\n\n#### CloudWatch\n\n- Create a `24_hours` interval scheduled job.\n- Apply that job as the trigger of the `less_crawler` lambda.\n\n#### DynamoDB\n\n- Create a table with name of `less-crawler-dev` or anything you want, just make sure to change the `dynamoTable` value in Go code, too.\n\n- Primary partition key: `date` (String).\n\n- Primary sort key: `sort` (Number).\n\n#### API Gateway\n\n- Create a root `/` GET API to forward/proxy the HTTP request to the URL of `index.html` file on S3 bucket.\n- Create a `/api/v1/trending` POST API which called the `less_caterer` lambda.\n- You may have to allow the CORS permission on APIs, too.\n- Deploy the APIs to a stage (E.g: `dev`).\n\n\nOpen browser and follow the link to the `GET /` API, you now have a simple serverless website up and running on AWS. Congrats :)\n\n![less](https://github.com/lnquy/less/blob/master/images/less-demo.jpg)\n\n## License\n\nThis project is under the MIT License. See the [LICENSE](https://github.com/lnquy/less/blob/master/LICENSE) file for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flnquy%2Fless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flnquy%2Fless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flnquy%2Fless/lists"}