@mathrunet/masamune_cloudflare
v3.3.1
Published
Manages packages on Cloudflare Workers for the server portion of the Masamune framework.
Maintainers
Readme
[GitHub] | [YouTube] | [Packages] | [X] | [LinkedIn] | [mathru.net]
Just load the package in index.ts and pass the predefined data to the methods to implement the server side.
Also, katana_functions_firebase can be used to execute server-side functions from methods defined on the client side, allowing for safe implementation.
Installation
Install the following packages
npm install @mathrunet/masamune_cloudflareImplementation
Pass the return value of the deploy function to export default. It is defined by passing various Workers to the deploy function.
import * as m from "@mathrunet/masamune_cloudflare";
// Define [m.Functions.xxxx] for the functions to be added to Workers.
//
// Workersに追加する機能を[m.Functions.xxxx]を定義してください。
export default m.deploy(
[
// Worker for Test.
m.TestWorkers.test,
],
);Rules
WorkersOptions.rules accepts a rules.json configuration. Import the JSON
file and pass it to deploy when multiple Cloudflare packages should share the
same rules.
import * as m from "@mathrunet/masamune_cloudflare";
import rulesJson from "../rules.json";
export default m.deploy(
[
m.TestWorkers.test,
],
{
rules: rulesJson,
},
);rules.json groups rules by target. Database rules and storage rules use the
same path pattern and access rule format.
{
"version": "1",
"rules": {
"database": {
"main": {
"read": "allow",
"write": "server"
},
"{uid}/users/{uid}": {
"read": { "type": "path", "param": "uid" },
"write": { "type": "field", "field": "ownerId", "server": true }
}
},
"storage": {
"public/**": {
"read": "allow",
"write": "authenticated"
},
"images/{uid}/**": {
"read": { "type": "path", "param": "uid" },
"write": { "type": "path", "param": "uid", "server": true }
}
}
}
}Supported access values are deny, allow, authenticated, server,
{ "type": "field", "field": "..." }, and
{ "type": "path", "param": "..." }. { "type": "fieldMatch" } is still
accepted for compatibility.
GitHub Sponsors
Sponsors are always welcome. Thank you for your support!
