diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5209800d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: node_js - -node_js: '12' - -script: - - npm run lint - - npm run i18n:validate - - npm run cofactsapi - - npm run test -- --coverage - -after_success: - - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js diff --git a/README.md b/README.md index 1f3296a0..bce959b6 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Please follow all the steps in [LINE official tutorial](https://developers.line. Create `.env` file from `.env.sample` template, at least fill in: ``` -API_URL=https://dev-api.cofacts.org/graphql +API_URL=https://dev-api.cofacts.tw/graphql LINE_CHANNEL_SECRET= LINE_CHANNEL_TOKEN= LINE_LOGIN_CHANNEL_ID= @@ -65,6 +65,10 @@ The server will be started on `localhost:5001` (or the `PORT` you specified in y If you wish to stop the peripherals, run `docker-compose stop`. +### Unit test + +Just run `npm test`. It will automatically spin up the aforementioned docker and run unit tests. + ### Get LINE messages to your local machine We recommend [using `ngrok`](https://medium.com/@Oskarr3/developing-messenger-bot-with-ngrok-5d23208ed7c8#.csc8rum8s) to create a public address that directs the traffic from LINE server to your local machine. With `ngrok` in your path, just @@ -230,10 +234,6 @@ To use Dialogflow, ## Production Deployment -You have two deployment options: - -### Option 1. Build docker image & deploy using docker-compose - Prepare `.env` file (which should be identical to your deployment environment) and run `docker build .` to generate docker image. `.env` will be copied over to the builder image to generate LIFF static file with the env. @@ -245,52 +245,6 @@ You can test the built image locally using the `docker-compose.yml`; just uncomm For production, please see [rumors-deploy](https://github.com/cofacts/rumors-deploy/) for sample `docker-coompose.yml` that runs such image. -### Option 2. Deploy to Heroku - -If you would like to start your own LINE bot server in production environment, this section describes how you can deploy the line bot to your own Heroku account. - -#### Get the server running - -You can deploy the line bot server to your own Heroku account by [creating a Heroku app and push to it](https://devcenter.heroku.com/articles/git#creating-a-heroku-remote). - -Despite the fact that we don't use `Procfile`, Heroku still does detection and installs the correct environment for us. - -#### Prepare storage services - -##### Redis - -We use Redis to store conversation context. - -Use the env var `REDIS_URL` to specify how chatbot should link to the Redis server. - -On Heroku, you can [provision a Heroku Redis addon](https://elements.heroku.com/addons/heroku-redis) to get redis. -It sets the env var `REDIS_URL` for you. - -##### MongoDB - -We use MongoDB to store users' visited posts. It's the data source for related GraphQL APIs. - -Use the env var `MONGODB_URI` to specify your MongoDB's connection string. - -[MongoDB Atlas Free Tier cluster](https://docs.atlas.mongodb.com/tutorial/deploy-free-tier-cluster/) to start with. - -#### Configurations - -Besides previously mentioned `MONGODB_URI` and `REDIS_URL`, -you will still have to set the following config vars manually: - -``` -$ heroku config:set API_URL=https://cofacts-api.g0v.tw/graphql -$ heroku config:set SITE_URLS=https://cofacts.g0v.tw -$ heroku config:set LINE_CHANNEL_SECRET= -$ heroku config:set LINE_CHANNEL_TOKEN= -$ heroku config:set LIFF_URL= -$ heroku config:set FACEBOOK_APP_ID= -$ heroku config:set JWT_SECRET= -``` - -Consult `.env.sample` for other optional env vars. - ## Google Analytics Events table Sent event format: `Event category` / `Event action` / `Event label` diff --git a/src/lib/__tests__/sharedUtils.js b/src/lib/__tests__/sharedUtils.js index 593e312a..138583aa 100644 --- a/src/lib/__tests__/sharedUtils.js +++ b/src/lib/__tests__/sharedUtils.js @@ -14,7 +14,7 @@ describe('getArticleURL and extractArticleId', () => { it('use the default SITE_URL', () => { const utils = require('../sharedUtils'); expect(utils.getArticleURL('AWDZYXxAyCdS-nWhumlz')).toMatchInlineSnapshot( - `"https://cofacts.g0v.tw/article/AWDZYXxAyCdS-nWhumlz"` + `"https://cofacts.tw/article/AWDZYXxAyCdS-nWhumlz"` ); }); diff --git a/src/lib/sharedUtils.js b/src/lib/sharedUtils.js index ed140d96..255ccb1b 100644 --- a/src/lib/sharedUtils.js +++ b/src/lib/sharedUtils.js @@ -7,9 +7,7 @@ import dateFnsFormat from 'date-fns/format'; import dateFnsFormatDistanceToNow from 'date-fns/formatDistanceToNow'; import GraphemeSplitter from 'grapheme-splitter'; -const SITE_URLS = (process.env.SITE_URLS || 'https://cofacts.g0v.tw').split( - ',' -); +const SITE_URLS = (process.env.SITE_URLS || 'https://cofacts.tw').split(','); /** * prefilled text for LIFF sendMessage()