LambdaDB is a standalone Express Server that sits on top of your database. It makes your database Lambda ready by managing the connection pool and exposing a secure API.
Supported databases:
- MySQL
-
- Clone repository
git clone https://github.com/Theo-/lambdaDB.git
-
- Install dependencies
npm install
-
- Configure database connection
Fill the config.js file:
module.exports = function(environment) {
return {
host: "database_host",
password: "database_password",
username: "database_username",
database: "database_name",
port: 3306,
secretToken: "secretToken",
// Enable users, will create a lambdadb_config
// database following the format in
// databases/lambdadb_config.json
enableUsers: true
}
}Remark that the environment is passed to the function so you can easily modify those credentials at running time. One use case would be to swap credentials when in a testing environment.
The secretToken is used to authenticate the request to the LambdaDB server.
-
- Start the server
npm start
-
- Use the LambdaDB npm package to access your database.
You can find the documentation in the LambdaDB client repository.
We don't want everybody to have access to this server, that's why LambdaDB uses a secretToken (set in the configuration file). This secretToken must be passed through a X-Access-Token header for every request.
Users are optional, they allow multiple users to connect to the LambdaDB server with different set of permissions. One use case would be to restrict access of users to their own databases.
LambdaDB users map to SQL users. Therefore, in order to enable users, LambdaDB must have root access.
LambdaDB will create a lambdadb_config database to manage users with the template databases/lambdadb_config.json.
LambdaDB has a built-in template parsing engine that allows easy reproducibility of databases and tables.
Example:
{
"name": "Example database",
"type": "database",
"tables": [
{
"name": "users",
"columns": [
{
"name": "uid",
"type": "BIGINT",
"auto_increment": true
}
]
}
]
}You can check the lambdadb_config database template.
POST /
Body:
{
query: "SELECT * FROM users"
}
Results:
{
"success": true,
"data": [
{
firstName: "",
....
},
...
]
}