Skip to content

Commit

Permalink
Working attempt at adding count function
Browse files Browse the repository at this point in the history
  • Loading branch information
ineffyble committed Oct 31, 2018
1 parent 54b0622 commit 89ca92c
Show file tree
Hide file tree
Showing 10 changed files with 4,065 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Gemfile.lock
internetfreedomhack-website.iml
vendor
node_modules
functions/dist
yarn-error.log
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ exclude:
- vendor
- docker-compose.yml
- functions
- build.sh
- package.json

# PLUGIN SETTINGS
maps:
Expand Down
3 changes: 0 additions & 3 deletions build.sh

This file was deleted.

18 changes: 0 additions & 18 deletions functions/count.js

This file was deleted.

13 changes: 0 additions & 13 deletions functions/package-lock.json

This file was deleted.

7 changes: 0 additions & 7 deletions functions/package.json

This file was deleted.

21 changes: 21 additions & 0 deletions functions/src/count.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import request from 'request';

const API_ENDPOINT =
"https://pretix.eu/api/v1/organizers/thoughtworks/events/IFH-DE/orders/";

exports.handler = (event, context, callback) => {
request({
url: API_ENDPOINT,
method: 'GET',
json: true,
headers: {
"Authorization": `Token ${process.env.PRETIX_API_KEY}`
},
}, (error, response, body) => {
if (error) {
callback({ statusCode: 500, body: String(error) }, null);
} else {
callback(null, { statusCode: 200, body: `${body.count}`});
}
});
};
2 changes: 2 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
functions = "functions/dist"
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "internetfreedomhack-website",
"version": "1.0.0",
"scripts": {
"serve-lambda": "netlify-lambda serve functions/src",
"build-lambda": "netlify-lambda build functions/src",
"build": "jekyll build && yarn run build-lambda"
},
"dependencies": {
"netlify-lambda": "^1.0.2",
"request": "^2.88.0"
}
}
Loading

0 comments on commit 89ca92c

Please sign in to comment.