Giter VIP home page Giter VIP logo

foo's Introduction

foo

Example web application with clojure for a repl-driven development demonstration. And some capabilities of clojure applications in terms of web micro-services:

  • Writing an always up-to-date swagger definition yaml with swagger1st
paths:
  /users:
    get:
      summary: get users
      description: |
        get all user ids
      tags:
        - users
        - awesome
      # Hint: here we reference the actual Clojure function to call when this request comes in
      operationId: foo.handlers/get-all-users
  • Writing SQL queries with (surprise) SQL syntax - hugsql
-- :name get-all-user-ids :? :*
-- :doc Get all user ids we have
SELECT id FROM users
  • Migrating the database with ragtime
ALTER TABLE users ADD COLUMN age INTEGER DEFAULT NULL
  • Wiring the dependencies of the application and managing the state - mount
(mount/start)
  • Getting the synergie of all those things together using REPL and the text editor of your choice

Prerequisites

  • Brain
  • Laptop
  • Java 8 (sudo apt-get install openjdk-8-jre)
  • Leiningen installed - (wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -O $HOME/bin && chmod u+x ~/bin/lein)
  • Local postgresql user: postgres, password: postgres with a database foo freshly created and available
  • Being able to run this repository without huge stacktraces with lein run or at least lein repl
  • Preferably - your favorite text editor and the way to connect to a REPL from it (can assist with emacs/spacemacs setup for now, approach me beforehand if you have any questions about cursive/vim/lighttable)
  • Alternatively (for ubuntu 16.04 and later) - emacs-2.4.4+ + spacemacs:
sudo apt-get install emacs24
#![ATTENTION] - erasing the old emacs config - please back up existing one 
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
git clone https://github.com/dixel/foo
cd foo
lein
emacs -nw src/foo/core.clj
<ALT>+<X> cider-jack-in <ENTER>

Plan

  • Starting it locally
  • Adding functionality to all the sides (migrating the database, adding new API endpoints, modifying internal logic)
  • Building an artifact, deploying to playground cluster

Running foo

lein run

or

lein repl
;starting without the database
(mount/start-without #'foo.storage/database)
;or if postgres database is in place - starting everything
(mount/start)
; ... checking things
(mount/stop)

Navigate to the UI to get the Swagger UI for discovery.

foo's People

Contributors

dixel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.