-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adam Grohs
authored and
Adam Grohs
committed
Apr 14, 2019
1 parent
1c40d23
commit 71e226e
Showing
16 changed files
with
18,387 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: 'circleci/node:latest' | ||
steps: | ||
- checkout | ||
- run: yarn clean-install | ||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: sync-moltin-to-algolia-{{ checksum "package.json" }} | ||
test: | ||
docker: | ||
- image: 'circleci/node:latest' | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
- sync-moltin-to-algolia-{{ checksum "package.json" }} | ||
- run: yarn clean-install | ||
- run: yarn test | ||
release: | ||
docker: | ||
- image: 'circleci/node:latest' | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
- sync-moltin-to-algolia-{{ checksum "package.json" }} | ||
- run: yarn clean-install | ||
- run: npx semantic-release | ||
workflows: | ||
version: 2 | ||
build_test_release: | ||
jobs: | ||
- build | ||
- test: | ||
requires: | ||
- build | ||
- release: | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
requires: | ||
- test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
|
||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
|
||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Smartphone (please complete the following information):** | ||
|
||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# dependencies | ||
node_modules | ||
|
||
# misc | ||
.env | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.test.* | ||
*.spec.* | ||
/__tests__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": false, | ||
"trailingComma": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019-2025 UNIQUELY PARTICULAR LLC and Adam Grohs | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,76 @@ | ||
# sync-moltin-to-algolia | ||
# @particular./sync-moltin-to-algolia | ||
|
||
[![npm version](https://img.shields.io/npm/v/@particular./sync-moltin-to-algolia.svg)](https://www.npmjs.com/package/@particular./sync-moltin-to-algolia) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![CircleCI](https://circleci.com/gh/uniquelyparticular/sync-moltin-to-algolia.svg?style=svg)](https://circleci.com/gh/uniquelyparticular/sync-moltin-to-algolia) | ||
|
||
> Add/Update a Algolia indexed object when an object is created or modified in Moltin | ||
Asynchronous microservice that is triggered by [moltin](https://moltin.com) webhooks to add/update an object inside of [Algolia](https://algolia.com). | ||
|
||
Built with [Micro](https://github.com/zeit/micro)! 🤩 | ||
|
||
## 🛠 Setup | ||
|
||
Both an [Algolia](https://algolia.com) _and_ [moltin](https://moltin.com) account are needed for this to function. | ||
|
||
Create a `.env` at the project root with the following credentials: | ||
|
||
```dosini | ||
MOLTIN_CLIENT_ID= | ||
MOLTIN_CLIENT_SECRET= | ||
MOLTIN_WEBHOOK_SECRET= | ||
ALGOLIA_APP_ID= | ||
ALGOLIA_API_KEY= | ||
|
||
``` | ||
|
||
`MOLTIN_AGOLIA_INDICES` is optional but it is used to restrict which Moltin objects to generate Algolia indices for (ie. `products,brands,categories,collections,orders,customers`). | ||
|
||
Find your `MOLTIN_CLIENT_ID` and `MOLTIN_CLIENT_SECRET` inside of your [moltin Dashboard](https://dashboard.moltin.com)'s API keys. | ||
|
||
`MOLTIN_WEBHOOK_SECRET` can be anything you want. | ||
|
||
Find your `ALGOLIA_APP_ID` and `ALGOLIA_API_KEY` within your [Algolia Dashboard](https://www.algolia.com/dashboard) by going to `API keys` for your App. Note, `ALGOLIA_API_KEY` should be set to your Algolia `Admin API Key`, not your `Search-Only API Key`. | ||
|
||
## 📦 Package | ||
|
||
Run the following command to build the app | ||
|
||
```bash | ||
yarn install | ||
``` | ||
|
||
Start the development server | ||
|
||
```bash | ||
yarn dev | ||
``` | ||
|
||
The server will typically start on PORT `3000`, if not, make a note for the next step. | ||
|
||
Start ngrok (change ngrok port below from 3000 if yarn dev deployed locally on different port above) | ||
|
||
```bash | ||
ngrok http 3000 | ||
``` | ||
|
||
Make a note of the https `ngrok URL` provided. | ||
|
||
## ⛽️ Usage | ||
|
||
Next head over to the [moltin Webhook Settings](https://dashboard.moltin.com/app/settings/integrations) area, add a new integration (`Settings > Integrations` and click `Create`). | ||
|
||
Enter any name and description for your Integration. Moltin recommends you prefix the name with `DEVELOPMENT:` for any testing. | ||
|
||
Next, enter the `ngrok URL` from above and `MOLTIN_WEBHOOK_SECRET` that you saved inside `.env`. | ||
|
||
![URL and Secret Key](https://user-images.githubusercontent.com/950181/52846929-ca957980-3102-11e9-9a20-23b8139767ee.png) | ||
|
||
Now finally you'll want to configure what Moltin Observables (ie. `Products, Brands, Categories, Collections, Orders, Customers`) will cause this webhook to be invoked. In this example we want to monitor the `Products`, `Orders` and `Customers` observables and select the `Created`, `Updated` and `Deleted` box. | ||
|
||
Click Save to register your new Webhook with Moltin. | ||
|
||
## 🚀 Deploy | ||
|
||
You can easily deploy this function to [now](https://now.sh). | ||
|
||
_Contact [Adam Grohs](https://www.linkedin.com/in/adamgrohs/) @ [Particular.](https://uniquelyparticular.com) for any questions._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
roots: ['<rootDir>/src', '<rootDir>/tests'], | ||
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$', | ||
moduleFileExtensions: ['js', 'jsx', 'json', 'node'], | ||
verbose: true, | ||
testURL: 'http://localhost/' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "demo-sync-moltin-to-algolia", | ||
"alias": "particular-demo-sync-moltin-to-algolia.now.sh", | ||
"env": { | ||
"NODE_ENV": "production", | ||
"MOLTIN_CLIENT_ID": "@demo-moltin-client-id", | ||
"MOLTIN_CLIENT_SECRET": "@demo-moltin-client-secret", | ||
"MOLTIN_WEBHOOK_SECRET": "@demo-moltin-webhook-secret", | ||
"MOLTIN_AGOLIA_INDICES": "@demo-moltin-algolia-indices", | ||
"ALGOLIA_APP_ID": "@demo-algolia-app-id", | ||
"ALGOLIA_API_KEY": "@demo-algolia-api-key" | ||
}, | ||
"routes": [{ "src": "/(.*)", "dest": "/src" }], | ||
"builds": [ | ||
{ | ||
"src": "src/*.js", | ||
"use": "@now/node" | ||
} | ||
] | ||
} |
Oops, something went wrong.
71e226e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully aliased the URL https://demo-sync-moltin-to-algolia-jil3gmnm3.now.sh to the following aliases.