Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
A lightweight web library that combines the best of server-side rendering and client-side state management.
Simple, Fast, And Easy To Learn.
Visit Website
SaturJs is a lightweight, server-side rendering (SSR) library designed for building dynamic, fast-loading web applications with ease. It empowers developers to manage application state, handle components, and optimize rendering while maintaining full control over their architecture.
# Clone the starter template
git clone https://github.com/madhanmaaz/saturjs-quick-start
cd saturjs-quick-start
# Install dependencies
npm install
# Start development server
npm run dev
// server.js
const { setup, Router, renderPage } = require("saturjs")
const router = Router()
router.get("/", renderPage("index"))
module.exports = setup({
appRouter: router
})
src/index.html
<script server>
// server code
const title = "page title"
async function defServer(req, res, next) {
if(req.query.id == "2") {
res.send("user not found.")
}
return {
id: req.query.id
}
}
</script>
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ title }}</title>
</head>
<body>
<h1>Welcome to SaturJs</h1>
<p>User ID: {{ id }}</p>
<!-- import component & render component -->
<import src="./Counter.html" />
{{ $$.Counter() }}
</body>
</html>
src/Counter.html
the component must starts with caps.<template>
<button onclick="handler">Count {{ count }}</button>
</template>
<script>
const state = defProxy({
count: 0
})
defEvents({
handler() {
state.count++
}
})
</script>
<!-- Basic Expressions -->
{{ 1 + 1 }} <!-- Outputs: 2 -->
{{ username }} <!-- Variable interpolation -->
{{- html }} <!-- Unescaped HTML -->
{{# comments }} <!-- Not visible in output -->
<!-- Conditionals -->
{{ if(condition) }}
<p>True branch</p>
{{ else if(otherCondition) }}
<p>Else if branch</p>
{{ else }}
<p>Else branch</p>
{{/}}
<!-- Loops array -->
{{ for(value, index in array) }}
<p>{{ index }}: {{ value }}</p>
{{/}}
<!-- Loops object -->
{{ for(value, key in object) }}
<p>{{ key }} - {{ value }}</p>
{{/}}
<!-- Component Usage -->
{{ $$.Counter({ count: 0 }) }}
{{ $$["Counter"]({ count: 0 }) }}
<template>
<!-- Root element for the component; must contain only one root element -->
<div>
<!-- Component-specific event -->
<button onclick="handler">Count {{ count }}</button>
<!-- Access events from another component -->
<button onclick="Settings.open">Open Settings</button>
<!-- Pass arguments to a method -->
<button onclick="deleteNotes(id, 1, 2)">Delete Notes</button>
</div>
</template>
<script>
// Import libraries; these will automatically be bundled
const uuid = require("uuid");
const axios = require("axios");
// Define props that come from a parent component
const props = defProps({
title: String
});
// `defProxy` manages the state for this component.
// It stores all data relevant to this component.
const state = defProxy({
count: 0,
data: [],
users: []
});
// `defEvents` defines component-specific events.
// Events can be accessed from other components using `thisComponent.eventName`.
defEvents({
handler() {
state.count++;
},
openPanel() {
// Use `useSignal` to communicate with other components
useSignal("Panel").open = true;
}
});
// `defMethods` defines functions accessible within the template.
defMethods({
alter(value) {
return `${value}.`;
}
});
// `defWatch` monitors state changes; triggers when `count` changes
defWatch({
count(newValue, oldValue) {
console.log("Count changed from", oldValue, "to", newValue);
}
});
// Alert outside of `defLoad` throw an error
// alert("loaded"); // incorrect
// `defLoad` runs when the component is ready in the client
defLoad(() => {
alert("Component loaded"); // correct usage
});
// `defError` handles errors within the component
defError((error) => {
console.log("Error encountered:", error);
});
</script>
FAQs
A lightweight web library that combines the best of server-side rendering and client-side state management.
The npm package saturjs receives a total of 3 weekly downloads. As such, saturjs popularity was classified as not popular.
We found that saturjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.