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.
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.
Using Docker Compose is an all-in-one-solution for crud. Here are the necessary steps:
docker-compose.yml and paste the following into itversion: '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'
docker-compose upYou 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
Requirements:
The following steps should get crud up and running:
git clone git@github.com:gedankenessen/crud.gitcd crudlein runThat 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.
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).
With crud setup you can checkout the first steps section and make your first queries.
Last Edited: 2023.01.09; crud:1.2.0