First, you need to install the Lua on Beans CLI globally using npm:
npm install -g luaonbeans-cli
Once the CLI is installed, you can create a new empty project using the following command:
beans new my-project
Replace "my-project" with your desired project name.
Lua on Beans uses ArangoDB as its database. You can easily set it up using Docker Compose:
docker compose up arangodb -d
While ArangoDB is the default database for Lua on Beans, it's important to note that you have other options:
To use Lua on Beans without a database or with an alternative database, you'll need to adjust your configuration and potentially create a custom database adapter. Refer to the advanced configuration documentation for more details on setting up alternative database solutions.
With these steps completed, you now have a new Lua on Beans project set up with ArangoDB running. You're ready to start building your web application!
Check out our documentation for more information on how to structure your project, create routes, and interact with the database.
To connect your application to ArangoDB, you need to configure the database settings. Follow these steps:
config
folder in your project directory.database.json.arangodb.sample
file.database.json
.database.json
in your preferred text editor.
{
"system": {
"db_name": "_system",
"url": "http://127.0.0.1:8529",
"username": "root",
"password": "password"
},
"development": {
"db_name": "luaonbeans_dev",
"url": "http://127.0.0.1:8529",
"username": "root",
"password": "password"
},
"production": {
"db_name": "luaonbeans",
"url": "http://127.0.0.1:8529",
"username": "root",
"password": "password"
},
"test": {
"db_name": "luaonbeans_test",
"url": "http://127.0.0.1:8529",
"username": "root",
"password": "password"
},
"engine": "arangodb"
}
Now that you've configured your database connection, you need to create the actual database in ArangoDB. Follow these steps to create the database using the ArangoDB UI:
http://localhost:8529
if running locally).Repeat this process for each environment (development, production, test) you've defined in your database.json
file.
Note:
Ensure that the database names you create in the ArangoDB UI match exactly with the db_name
values in your database.json
file for each environment.
Now that you've set up your database, you're ready to run your Lua on Beans application. Follow these steps to start your app:
./luaonbeans -D .
I2024-09-29T19:10:06.510903:tool/net/redbean.c:1122:luaonbeans:41737] (cfg) program directory: .
I2024-09-29T19:10:06+031026:tool/net/redbean.c:7052:luaonbeans:41737] (srvr) listen http://127.0.0.1:8080
I2024-09-29T19:10:06+000057:tool/net/redbean.c:7052:luaonbeans:41737] (srvr) listen http://192.168.10.118:8080
I2024-09-29T19:10:06+000111:tool/net/redbean.c:7052:luaonbeans:41737] (srvr) listen http://192.168.165.0:8080
I2024-09-29T19:10:06+000047:tool/net/redbean.c:7052:luaonbeans:41737] (srvr) listen http://198.19.249.3:8080
I2024-09-29T19:10:06+000030:tool/net/redbean.c:7052:luaonbeans:41737] (srvr) listen http://192.168.229.0:8080
I2024-09-29T19:10:06+000028:tool/net/redbean.c:7052:luaonbeans:41737] (srvr) listen http://172.18.0.0:8080
I2024-09-29T19:10:06+000029:tool/net/redbean.c:7052:luaonbeans:41737] (srvr) listen http://192.168.164.0:8080
>:
Congratulations! You've successfully set up and run your Lua on Beans application. You can now start building your web application using the power of Lua, redbean.dev, and ArangoDB.