Git Product home page Git Product logo

aliyunfc-chotot-2-ding's Introduction

aliyunFC-chotot-2-ding

A simple nodejs8 serverless function to fetch ChoTot gateway api for rental information in district 1

Requirements

  • NodeJS 8.0 and NPM

  • AliCloud (AliYun) account with Function Compute(Alicloud serverless service) enabled

  • fcli to configure Function Compute from cli.

  • (Not required) AliCloud SLS for log collection

What is this

  • A Serverless function that i setup as a cronjob on Alicloud.

  • The cron is set to run hourly

  • The logic is as follow:

    1. Fetch a pre-created JsonBin array.

    2. Fetch data from ChoTot Gateway with pre-defined parameters for location i picked. In this case its District 1, Hochiminh city, VietNam.

    3. Using the JSONBIN array, filter through all the old listing that we have encountered in the past using list_id of the ads.

    4. Filter through all the ads listing with a MAX_PRICE hardcoded at 7 Millions VND. (this could be move to env variable now that i think of it)

    5. Send all the remainding posts information to DingTalk which I use at work everyday. Together with a link which i can click to go to the website orignal post.

    6. Append all the newly found list_id to the previous old posts list. Update the new list to JsonBin for next run.

How to use

git clone https://github.com/sluongng/aliyunFC-chotot-2-ding

cd aliyunFC-chotot-2-ding

npm install

npm test
  • You should be able to run and debug index.js locally.
  • Setup fcli with correct ~/.fcli/config.yaml
  • Run the following to init your function
fcli service create --service-name housing

fcli service function --service-name housing \
                      --function-name chotot \
                      --handler index.handler \
                      --runtime nodejs8 \
                      --code-dir .
  • Go to Alicloud console for logging and environment variable setups

  • There are 3 npm run commands: deploy, invoke, log for local development purposes

  • Run npm run live-test to execute all 3 commands sequentially for a live test run.

  • Timing trigger is not easy to setup via fcli so I suggest using web console for now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.