Building a backend server for a small sized apps can be a complex and time-consuming process. Blite offers a solution to simplify this process and get you up and running quickly.
Blite is a monolithic Node.js backend server app that provides built-in services such as routing, user authentication, database management, upload management, and email confirmation. This all-in-one solution aims to be lightweight and fast, making it a great choice for small to medium sized projects that need a backend server and database.
It's an open source project and you can check out the source code and docs here. You can run the demo app following way to see how it works.
const blite = require('blite');
blite.demo()
// Check out the demo app at http://localhost:3000
The following hello world example illustrates defining simple routes.
const blite = require('blite');
blite.init({
server:{
port: 8080
}
...
})
// Serve static files
blite.server.use("/static", blite.server.static(`www`) )
// Hello world
blite.server.get('/', (req, res) => {
res.send('Hello World!')
})
blite.start()
// Check out the example app at http://localhost:8080
Here are some examples of how you can use database with Blite.
const users = blite.db.addCollection('users', {unique: ['name']});
users.insert({
name: 'Odin',
age: 50
});
// Alternatively, insert array of documents
users.insert([{ name: 'Thor', age: 35}, { name: 'loki', age: 30}]);
// Find documents
const results = users.find({ age: {'$gt': 40} }).docs();
console.log(results)
// output:
// [
// {
// name: 'Odin',
// age: 50,
// meta: {
// revision: 1,
// created: 1676235325951,
// version: 0,
// updated: 1676235325952
// },
// '$ctrl': 1,
// id: '80f81115-3e82-4603-bb04-3dae2540f554'
// }
// ]
Conclusion
Blite is a simple and fast library that allows you to create a full stack web application in minutes. It has a lot of features that you can use to build your next project. You can check out the documentation here for more details. If you have any questions or suggestions, feel free to contact me.
Top comments (0)