This file contains hidden or 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
(ns monolith.routes | |
(:require [compojure.core :refer [defroutes GET POST wrap-routes]] | |
[compojure.route :as route] | |
[monolith.http :refer [ok unauthorized not-found]] | |
[monolith.logic.users :as users] | |
[monolith.logic.tokens :as tokens] | |
[monolith.utils :refer [throw+]] | |
[monolith.env :as env])) | |
(defn authorization->token [req] |
This file contains hidden or 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
(ns monolith.logic.users | |
(:require [cheshire.core :as json] | |
[environ.core :refer [env]] | |
[org.httpkit.client :as http] | |
[clojurewerkz.scrypt.core :as sc] | |
[yesql.core :as yesql] | |
[compojure.core :refer [defroutes POST]] | |
[monolith.db :as db] | |
[monolith.utils :refer [uuid flip throw+]] | |
[monolith.http :refer [ok bad-request]])) |
This file contains hidden or 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
{:up [" | |
create table stripe.events ( | |
id uuid primary key, | |
stripe_id varchar(50) not null, | |
object varchar(50) not null, | |
api_version varchar(20) not null, | |
livemode boolean not null, | |
pending_webhooks int not null, | |
request text, | |
type text not null, |
This file contains hidden or 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
-- name: get-stripe-events-by-id | |
select | |
id, | |
stripe_id, | |
object, | |
api_version, | |
livemode, | |
pending_webhooks, | |
request, | |
type, |
This file contains hidden or 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
(ns monolith.logic.events | |
(:require [monolith.db :as db] | |
[monolith.utils :as utils] | |
[monolith.http :refer [ok]] | |
[yesql.core :as yesql] | |
[compojure.core :refer [defroutes POST]])) | |
(yesql/defqueries "sql/stripe/events.sql" (db/yesql-conn)) | |
(defn req->params [{:keys [id] :as body}] |
This file contains hidden or 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
{:up [" | |
create table stripe.plans ( | |
id uuid primary key, | |
amount integer, | |
created timestamp, | |
currency text, | |
interval text, | |
interval_count integer, | |
livemode boolean, | |
name text, |
This file contains hidden or 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
-- name: get-stripe-plans | |
select | |
id, | |
amount, | |
created, | |
currency, | |
interval, | |
interval_count, | |
livemode, | |
name, |
This file contains hidden or 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
(ns monolith.stripe.http | |
(:require [monolith.utils :as utils] | |
[cheshire.core :as json]) | |
(:refer-clojure :exclude [get])) | |
(defn make-url [& args] | |
(clojure.string/replace (apply str args) #"(\w+)\/+" "$1/")) | |
(defn req-body [m] | |
(condp (utils/flip contains?) m |
This file contains hidden or 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
(ns monolith.stripe.http-test | |
(:require [clojure.test :refer :all] | |
[monolith.stripe.http :refer :all]) | |
(:refer-clojure :exclude [get]) | |
(:import (java.util Date) | |
(java.text SimpleDateFormat))) | |
(deftest make-url-test | |
(testing "nil" | |
(is (= "" (make-url nil)))) |
This file contains hidden or 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
(ns monolith.stripe.plans.db | |
(:require [monolith.http :refer [ok]] | |
[monolith.env :refer [env]] | |
[monolith.db :as db] | |
[monolith.utils :as utils] | |
[monolith.stripe.plans.api :as plans] | |
[yesql.core :as yesql] | |
[compojure.core :refer [defroutes GET]]) | |
(:refer-clojure :exclude [list])) |