Skip to content
dpetrovics edited this page Nov 11, 2014 · 11 revisions

Overview:

Services Used:

Important Libraries:

  • Liberator for Resource Management:
  • Logging: Timbre
  • Authentication / Authorization: Friend

Environmental Variables:

  • GEONAMES_KEY - To get current timezone, in location.cljx.
  • DEFAULT_TIMEZONE - For time.cljx.
  • COUCH_URL - Url for your CouchDB.
  • DATABASE_NAME - Database name of your CouchDB.
  • COUCH_VIEW_DIRECTORY - Where your CouchDB views live.
  • COUCH_VIEW_SUFFIX - If you use different view names in production and staging.
  • REDIS_URL - Url of your redis service.
  • SESSION_STORE - Or :redis by default.
  • CRYPTO_KEY - For Base 64 encoding/decoding.

Service Tokens:

  • FB_APP_SECRET
  • FB_CLIENT_ID
  • FB_CLIENT_SERVICE

CLJX Namespaces

Algebra.cljx

Semigroup protocol with 'plus' implementation - gives you monoids for cljs and clj to "add" maps or vectors.

AWS.cljx

Utilities for managing image uploads to Amazon's S3, and Cloudfront CDN.

CouchDB.cljx

Schemas and helper functions related to CouchDB: connecting, creating/deleting/updating documents or attachments, getting documents, querying views, and some helpers for marking the creation or update timestamps for a document, and other utility functions.

Environmental Variables: COUCH_URL, DATABASE_NAME, COUCH_VIEW_SUFFIX (We use different views for production and staging, so we can experiment with new views before doing a production release.)

Location.cljx

Google Locations API

Schema.cljx

Common schemas that we use in our projects, and helper functions such as 'toggle-optional'

Time.cljx

clj-time helpers. Include convenience functions for creating timestamps, computing intervals, conversions between various time formats, timezone changes, etc.

Util.cljx

A smorgasbord of helper functions for clj and cljs, spanning accounting, Enlive, core.async, form validation, map and vector operations, time/date manipulation, string formatting, and more.

Validation.cljx

Common validators we use, including some Validateur helpers.

CLJ Namespaces

Lifecycle.clj

Functions for controlling the lifecycle of an application, deprecating in favor of Component

Session.clj

Functions for managing our Redis session store. Configuration using the REDIS_URL environmental variable, cache expiration, etc.

Couchdb/Testing.clj

defdbtest is a macro that we use to test our CouchDB Views. You'll need to setup Erica in order for this to work. You should pass in a vector of design-docs to use with the :required-views option. Make sure that you have a COUCH_URL environmental variable (see CouchDB.cljx above). The macro creates a test database on your current CouchDB, binds the database to test-database for the duration of the body, creates the required views in the test database via Erica, evaluates all the tests in the body, and then deletes the test database and returns to your original db configuration.

Middlewares:

Bare.clj

If the request starts with "www.", strips it from the request, and forces a permanent (301) redirect. (We use a "bare" domain).

Config.clj

Injects a :config key into the request, with :mode, :dev?, and :cdn keys.

UUID.clj

Injects a :uuid into each request; useful for logging purposes. TODO: We don't have to heroku-request-id anymore. (Just generates a random one, which is fine).

Request_Method.clj

Some of our forms have a "_method" keyword so our Liberator endpoints can process DELETE requests.

Other:

TODO: Friend.clj, Liberator.clj, Log.clj, Oauth.clj, Session.clj, Config.clj, Ring.clj, Crypto.clj, Facebook.clj, Friend/json.clj

Clone this wiki locally