freestyle.sh is a cloud platform in early development that replaces traditional databases with persistent javascript objects. Write code as if your data is in memory and never think about it's underlying storage mechanisms again. We'll statically and dynamically optimize your code to make efficient queries inside our cloudstate environment.
// The @cloudstate decorator makes this class's data persistent.
// Data can only be augmented and retrieved through the class's
// methods. There's nothing you have to do for your data to be
// saved, it's automatically saved for you.
@cloudstate
class Counter {
// Giving a class a static id makes it a singleton which you
// can reference in other places in your code.
static id = "counter";
// This data is automatically persisted for you.
count = 0;
increment() {
this.count++;
}
getCount() {
return this.count;
}
}
// Gets a reference to the singleton instance of Counter.
// Your methods are executed and optimized inside your
// cloudstate database, not in your web server.
const counter = useCloud<typeof Counter>("counter");
// Call a method on counter from anywhere in your backend or
// frontend code to execute the method on the database.
await counter.increment();
Please note that cloudstate is not persistent during local development. It will be cleared when you restart the dev server. If you significantly change your data models during development, restart the dev server to clear the data.
install dependencies
npm i
run the development server
npx freestyle dev
build your project
npx freestyle build
log into freestyle using github
npx freestyle login
deploy to freestyle.sh (beta)
npx freestyle deploy