Middleware
Dubnium has built-in Express middleware functions to manage Records. Data is never sent to the client without your permission.
Last updated
app.get('/new', middleware.create({ from:"query", key:"tag" }, { from:"query", key:"content" }), (req, res) => {
// Creates a record with the tag and content from the query
})app.get('/:tag', middleware.get({ from:"params", key:"tag" }), (req, res) => {
// Access the record directly from req.record, if it exists
})app.get('/db', middleware.db(), (req, res) => {
// Access the database directly from req.db
})app.get('/', middleware.delete({ from:"headers", key:"id" }), (req, res) => {
res.send('Account deleted.')
})app.get('/', middleware.edit({ from:"body" }, { from:"content" }), (req, res) => {
res.send('Account edited!')
})app.get('/', middleware.other('function', ...args), (req, res) => {
res.send(`Ran ${req.db.function} with args ${req.db.args}`)
// req.db['function'] is the requested function
// req.db.function is the name of the requested function
// req.db.args is the requested args
// req.db.result is the result of the function
})