dragonroll/plugins/dnd-5e/backend/main.js
BinarySandia04 62471fa858
Some checks failed
test / run-tests-client (push) Successful in 18s
test / run-tests-backend (push) Failing after 15s
More documentation and sockets now work
2024-10-15 14:50:14 +02:00

40 lines
1.1 KiB
JavaScript

// Entrypoint
let Api;
function Main(api){
Api = api;
console.log("Hello World from backend!");
// Create our module in the backend. We only need the package name, it must be equal to the one that
// we made inside the client
let dndModule = Api.createModule('dnd-5e');
let itemModel = Api.createModel("item", {
name: { type: "String", required: true, default: "New item"},
type: { type: "String", required: true, default: "Item" },
info: { type: "Object" }, // For preview only
data: { type: "Object" }, // Advanced item
book: { type: "ObjectId", ref: "Book"},
campaign: { type: "ObjectId", ref: "Campaign"},
});
dndModule.router.get('/testing', (req, res) => {
/*
let item = itemModel.create({
name: "Test item!",
type: "The test item"
})
*/
console.log("FUNCIONA!!!!");
res.json({
status: "ok"
})
})
Api.socket.on("test", () => console.log("test"));
// Api.router.createModelRoutes(itemModel, 'item');
}
export { Main, Api };