Milestone 0: import zappier billing, Verae middleware, and Zapier research

Compose-ready workspace: packages/zappier (rate card, portal, Stripe),
packages/verae-zapier-middleware (timestamp + NATS), packages/verae-zapier
(CLI app), vendor/zapier-platform, and research/zapier vendor corpus.

Gate 0 structure checks pass. Product code and research are not yet wired.
This commit is contained in:
George Lambert 2026-09-09 02:37:36 -04:00
commit b4150c8250
1364 changed files with 6814366 additions and 0 deletions

View file

@ -0,0 +1,6 @@
build
docs
node_modules
*.log
.environment
.env

View file

@ -0,0 +1,7 @@
language: node_js
node_js:
- 8.10.0
before_script: 'npm install -g zapier-platform-cli'
script: 'zapier test'
notifications:
email: false

View file

@ -0,0 +1,7 @@
# HTTP Middleware Example App For Zapier Platform
[![Build Status](https://travis-ci.org/zapier/zapier-platform-example-app-middleware.svg?branch=master)](https://travis-ci.org/zapier/zapier-platform-example-app-middleware)
A simple app that demonstrates the use of HTTP before and after middleware.
> We recommend using the zapier-platform-cli and `zapier-platform init .`  to create an app - youll be presented with a list of currently available templates to start with.

View file

@ -0,0 +1,65 @@
const _ = require('lodash');
const recipe = require('./triggers/recipe');
const movie = require('./triggers/movie');
// HTTP before middleware that adds sorting query params.
// We want *every* request to our API to be sorted in reverse chronological order.
// Applying this middleware guarantees this.
const addSortingParams = (request /*, z */) => {
request.params = _.extend({}, request.params, {
_sort: 'id',
_order: 'desc',
});
return request;
};
// HTTP after middleware that checks for errors in the response.
const handleErrors = (response, z) => {
// Prevent `throwForStatus` from throwing for a certain status.
if (response.status === 456) {
response.skipThrowForStatus = true;
}
// Throw an error that `throwForStatus` wouldn't throw (correctly) for.
else if (response.status === 200 && response.data.success === false) {
throw new z.errors.Error(response.data.message, response.data.code);
}
return response;
};
// Now we can roll up all our behaviors in an App.
const App = {
// This is just shorthand to reference the installed dependencies you have. Zapier will
// need to know these before we can upload
version: require('./package.json').version,
platformVersion: require('zapier-platform-core').version,
beforeRequest: [
// add our before middlewares
addSortingParams,
],
afterResponse: [
// add our after middlewares
handleErrors,
],
resources: {},
// If you want your trigger to show up, you better include it here!
triggers: {
[recipe.key]: recipe,
[movie.key]: movie,
},
// If you want your searches to show up, you better include it here!
searches: {},
// If you want your creates to show up, you better include it here!
creates: {},
};
// Finally, export the app.
module.exports = App;

View file

@ -0,0 +1,26 @@
{
"name": "zapier-platform-example-app-middleware",
"version": "1.0.0",
"description": "An example app for the Zapier platform.",
"repository": "zapier/zapier-platform-example-app-middleware",
"homepage": "https://zapier.com/",
"author": "Bryan Helmig <bryan@zapier.com>",
"license": "BSD-3-Clause",
"main": "index.js",
"scripts": {
"test": "mocha --recursive"
},
"engines": {
"node": ">=8.10.0",
"npm": ">=5.6.0"
},
"dependencies": {
"lodash": "4.18.1",
"zapier-platform-core": "19.1.0"
},
"devDependencies": {
"mocha": "^5.2.0",
"should": "^13.2.0"
},
"private": true
}

View file

@ -0,0 +1,54 @@
/* globals describe, it */
require('should');
const zapier = require('zapier-platform-core');
const App = require('../index');
const appTester = zapier.createAppTester(App);
describe('triggers', () => {
describe('new recipe trigger', () => {
it('should load recipes', (done) => {
appTester(App.triggers.recipe.operation.perform)
.then((results) => {
results.should.be.an.Array();
results.length.should.be.above(1);
// Make sure the results are ordered by id desc
let i = 0;
while (i < results.length - 1) {
const cur = results[i];
const nxt = results[i + 1];
cur.id.should.be.aboveOrEqual(nxt.id);
i++;
}
done();
})
.catch(done);
});
});
describe('new movie trigger', () => {
it('should load movies', (done) => {
appTester(App.triggers.movie.operation.perform)
.then((results) => {
results.should.be.an.Array();
results.length.should.be.above(1);
// Make sure the results are ordered by id desc
let i = 0;
while (i < results.length - 1) {
const cur = results[i];
const nxt = results[i + 1];
cur.id.should.be.aboveOrEqual(nxt.id);
i++;
}
done();
})
.catch(done);
});
});
});

View file

@ -0,0 +1,41 @@
module.exports = {
key: 'movie',
noun: 'Movie',
display: {
label: 'New Movie',
description: 'Trigger when a new movie is added.',
},
operation: {
perform: {
url: 'https://auth-json-server.zapier-staging.com/movies',
params: {
// Just a demo, this is NOT how you normally do authentication.
// Refer to https://docs.zapier.com/platform/reference/cli-docs#authentication
api_key: 'secret',
},
},
// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example
// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of
// returned records, and have obviously dummy values that we can show to any user.
sample: {
id: 1,
releaseDate: 1472069465,
title: 'Test Title',
genre: 'Sci-Fi',
},
// If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom
// field definitions. The result will be used to augment the sample.
// outputFields: () => { return []; }
// Alternatively, a static field definition should be provided, to specify labels for the fields
outputFields: [
{ key: 'id', label: 'ID' },
{ key: 'releaseDate', label: 'Release Date' },
{ key: 'title', label: 'Title' },
{ key: 'genre', label: 'Genre' },
],
},
};

View file

@ -0,0 +1,48 @@
module.exports = {
key: 'recipe',
// You'll want to provide some helpful display labels and descriptions
// for users. Zapier will put them into the UX.
noun: 'Recipe',
display: {
label: 'New Recipe',
description: 'Trigger when a new recipe is added.',
},
// `operation` is where we make the call to your API
operation: {
perform: {
url: 'https://auth-json-server.zapier-staging.com/recipes',
params: {
// Just a demo, this is NOT how you normally do authentication.
// Refer to https://docs.zapier.com/platform/reference/cli-docs#authentication
api_key: 'secret',
},
},
// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example
// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of
// returned records, and have obviously dummy values that we can show to any user.
sample: {
id: 1,
createdAt: 1472069465,
name: 'Best Spagetti Ever',
authorId: 1,
directions: '1. Boil Noodles\n2.Serve with sauce',
style: 'italian',
},
// If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom
// field definitions. The result will be used to augment the sample.
// outputFields: () => { return []; }
// Alternatively, a static field definition should be provided, to specify labels for the fields
outputFields: [
{ key: 'id', label: 'ID' },
{ key: 'createdAt', label: 'Created At' },
{ key: 'name', label: 'Name' },
{ key: 'directions', label: 'Directions' },
{ key: 'authorId', label: 'Author ID' },
{ key: 'style', label: 'Style' },
],
},
};