Table of Contents
ducere
is a CLI tool for Basolato framework such as rake
/php artisan
.
Create new project
pwd
> /user/local/src
ducere new my_project
> Created project /user/local/src/my_project
pwd
> /user/local/src
mkdir my_project
cd my_project
ducere new .
> Created project /user/local/src/my_project
Run develop server with hot reload
Usage:
serve [optional-params]
Run dev application with hot reload
Options:
-h, --help print this cligen-erated help
--help-syntax advanced: prepend,plurals,..
--version bool false print version
-p=, --port= int 5000 set port
-f, --force bool false set force
--httpbeast bool false set httpbeast
--httpx bool false set httpx
ducere serve
The default port is 5000. If you want to change it, specify with option -p
ducere serve -p:8000
You can change host by editing env of config.nims
putEnv("HOST", "127.0.0.2")
You can choose httpbeast or httpx insted of asynchttpserver for basolato core server.
ducere serve --httpbeast
ducere serve --httpx
Compiling for production.
Usage:
build [optional-params] [args: string...]
Build for production.
Options:
-h, --help print this cligen-erated help
--help-syntax advanced: prepend,plurals,..
--version bool false print version
-p=, --port= int 5000 set port
-w=, --workers= uint 0 set workers
-f, --force bool false set force
--httpbeast bool false set httpbeast
--httpx bool false set httpx
-a, --autoRestart bool false set autoRestart
-o=, --optimize= string "memory" memory|speed
By default, it will be compiled to run 5000 port and single threadand and multiple processing.
When you build application, shell script file named startServer.sh
is generated. Run this file to start server.
ducere build
./startServer.sh
> running 4 processes
> Basolato uses config file '/basolato/.env'
> Basolato uses config file '/basolato/.env'
> Basolato uses config file '/basolato/.env'
> Basolato uses config file '/basolato/.env'
> Basolato based on asynchttpserver listening on 0.0.0.0:8000
> Basolato based on asynchttpserver listening on 0.0.0.0:8000
> Basolato based on asynchttpserver listening on 0.0.0.0:8000
> Basolato based on asynchttpserver listening on 0.0.0.0:8000
You can switch port by setting -p
option.
ducere build -p:8000
You can set the number of processes to run by setting workers
. The default is 0, which creates as many processes as the number of CPU cores in the build environment.
ducere build --workers=2
or
ducere build -w=2
To setting autoRestart
true, a shell that automatically restarts the application when it fails with some error is generated.
# autoRestart = false
./main & ./main & ./main & ./main
# autoRestart = true
while [ 1 ]; do
./main & \
./main & \
./main & \
./main
done
You can change host by editing env of config.nims
putEnv("HOST", "127.0.0.2")
You can choose httpbeast or httpx insted of asynchttpserver for basolato core server.
ducere build --httpbeast
ducere build --httpx
You can choose optimize option for memory or speed.
If memory is selected, ORC
is used for less memory consumption. If speed is selected, markAndSweep is used for more throughput.
ducere build --optimize=memory
> nim c --mm:orc -d:useMalloc ... main
ducere build --optimize=speed
> nim c --mm:markAndSweep -d:useRealtimeGC ... main
ducere migrate
This is a alias for nim c -r migrations/migrate
ducere migrate --reset --seed
This is an alias for nim c -r database/migrations/migrate
- options
--reset
Drop tables and re-migrate.--seed
Executedatabase/seeders/seed
after migration.
Create new file
Create config.nims
for database connection, logging, session-timeout configuation.
ducere make config
Generate new SECRET_KEY
in .env
ducere make key
Create new controller
ducere make controller user
>> app/http/controllers/user_controller.nim
ducere make controller sample/user
>> app/http/controllers/sample/user_controller.nim
ducere make controller sample/sample2/user
>> app/http/controllers/sample/sample2/user_controller.nim
Create new view template.
layout
is a part of components. page
is a view that called by controller.
ducere make layout buttons/success_button
>> app/http/views/layouts/buttons/success_button_view.nim
ducere make page login
>> app/http/views/pages/login_view.nim
It you add --scf
option for view creating command, SCF view will be created.
ducere make layout buttons/success_button --scf
ducere make page login --scf
Create new migration file
ducere make migration create_user
>> migrations/migration20200219134020create_user.nim
- Create top level domain model(=aggregate)
ducere make model circle
in app/models
circle
├── circle_entity.nim
├── circle_repository_interface.nim
├── circle_service.nim
└── circle_value_objects.nim
in app/queries
circle
└── circle_query.nim
in app/repositories
circle
└── circle_repository.nim
ducere make model circle/user
in app/models
circle
├── circle_entity.nim
├── circle_repository_interface.nim
├── circle_service.nim
├── circle_value_objects.nim
└── user
├── user_entity.nim
├── user_service.nim
└── user_value_objects.nim
Add new minimum value object boilerplate.
ducere make vo {arg1} {arg2}
arg1
specifies the name of the model to which the value object will be written. Ex: app/core/models/{model}/{model}_value_object
.
arg2
is a name of value object which should be Camel Case.
ducere make vo circle CircleName
>> add CircleName in app/models/circle/circle_value_objects.nim
ducere make vo circle/user UserName
>> add UserName in app/models/circle/user/user_value_objects.nim
Create new usecase.
At the same time, create query service
and query service interface
.
ducere make usecase sign signin
>> Updated app/di_container.nim
>> Created usecase in app/usecases/sign/signin_usecase.nim
>> Created query in app/data_stores/queries/sign/signin_query.nim
Clone this repository if you want to use bash-completion
for ducere
.
git clone https://github.com/itsumura-h/nim-basolato /path/to/nim-basolato
And add this shell script to ~/.bashrc
.
source /path/to/nim-basolato/completions/bash/ducere
Or, copy completion file to directory.
sudo install -o root -g root -m 0644 /path/to/nim-basolato/completions/bash/ducere /usr/share/bash-completion/completions/ducere