dragonroll/backend/services/api.js

80 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-10-05 10:57:47 +00:00
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
2024-10-05 12:31:09 +00:00
/**
* Test
*/
class Router {
constructor(){
}
/**
* @param {String} route
* Hola
*/
get(route){
}
/**
* @param {String} route
*
*/
post(route){
}
/**
* @param {String} route
*
*/
put(route){
}
/**
* @param {String} route
*
*/
delete(route){
}
}
2024-10-05 10:57:47 +00:00
class BackendApi {
2024-10-05 12:31:09 +00:00
#_plugin;
#_router;
2024-10-05 10:57:47 +00:00
/**
2024-10-05 12:31:09 +00:00
* This object is already created for you
2024-10-05 10:57:47 +00:00
* @param {plugin} Plugin instance
*/
constructor(plugin){
2024-10-05 12:31:09 +00:00
this._plugin = plugin;
this._router = new Router();
2024-10-05 10:57:47 +00:00
}
2024-10-05 12:31:09 +00:00
/**
* Gets the router for your plugin
* @type {Router} router
*/
get router(){
return this.router;
2024-10-05 10:57:47 +00:00
}
2024-10-05 12:31:09 +00:00
/**
* Returns a new database model for the plguin
* @param {String} name
* @param {Object} schema
* @returns {mongoose.model}
*/
2024-10-05 10:57:47 +00:00
createModel(name, schema){
return mongoose.model(name, new Schema(schema))
}
};
module.exports = {
2024-10-05 12:31:09 +00:00
BackendApi,
Router
2024-10-05 10:57:47 +00:00
}