Installation

About

crud can be hosted in multiple ways.


The quickest way to get crud up and running is Docker. Alternatively, you can use Docker Compose if you want to have a MongoDB present. Lastly, you can also just clone the crud repo and run the Clojure code directly.


Opting for Docker will mean your endpoints are saved in-memory, therefore lost upon restarts.

Docker

Using the official Docker image is the quickest way to get up and running:

docker run -p 3004:3004 gedankenessen/crud:1.2.0

You can now access crud via 127.0.0.1:3004.


crud will by default use an in-memory storage solution. You can however tell it to use a MongoDB that you provide. Checkout the customizing section to learn more.

Docker Compose

Using Docker Compose is an all-in-one-solution for crud. Here are the necessary steps:


  1. Create an empty folder for your crud deployment
  2. Create a docker-compose.yml and paste the following into it
version: '3.0'
services:
  mongo:
    image: 'mongo:6.0'
    restart: 'always'
    environment:
      - "MONGO_INITDB_ROOT_USERNAME=root"
      - "MONGO_INITDB_ROOT_PASSWORD=example"
    ports:
      - '27017:27017'
  crud:
    image: 'gedankenessen/crud:1.2.0'
    restart: 'always'
    ports:
      - '3004:3004'
  1. Open a terminal and navigate to your crud folder
  2. Run docker-compose up

You should now have two services running, a) a mongo service and b) a crud service. If thats the case crud will be available on 127.0.0.1:3004

Git

Requirements:

  • Git
  • Java (JDK8)
  • Clojure (1.10)
  • Leiningen
  • MongoDB (v6.0 preferred)

The following steps should get crud up and running:

  1. Clone the crud repo: git clone git@github.com:gedankenessen/crud.git
  2. Enter the project: cd crud
  3. Run the project via leiningen: lein run

That should start crud for you on 127.0.0.1:3004. Check out the customizing section to correctly configure crud to work with your MongoDB.

Customizing

You can tweak your crud experience with many options. The most important option is db-type which tells crud if it should use a in-memory solution (default, value:local) or a MongoDB (value:mongo).

So if you want to use a MongoDB either provide a environment variable CRUD_DB_TYPE with the value mongo or use the --db-type command line argument.

You can tweak further MongoDB related things such as the port, the desired collection, password etc. If you select MongoDB, crud will assume the default location of localhost:27017 with the user root and the password example.


Here is a table of all the possible options:


Environment Variable Command Line Argument Default Options
CRUD_DB_TYPE --db-type local mongo
CRUD_MONGO_URL --mongo-url localhost
CRUD_MONGO_PORT --mongo-port 27017
CRUD_MONGO_USER --mongo-user root
CRUD_MONGO_PW --mongo-pw example
CRUD_MONGO_DB --mongo-db crud-testing
CRUD_MONGO_SHOULD_AUTH --crud-should-auth false
CRUD_MONGO_AUTH_DB --crud-auth-db admin
CRUD_PORT --crud-port 3004
CRUD_ENV --crud-env prod
CRUD_TOKEN_SECRET --crud-token-secret secret
CRUD_TOKEN_VERSION --crud-token-version 0

You can adjust all that by either using environment variables (e.g docker run -- -e, docker-compose) or passing in different command line arguments (e.g lein run).

Whats next

With crud setup you can checkout the first steps section and make your first queries.



Last Edited: 2023.01.09; crud:1.2.0