chiselstrike

ChiselStrike abstracts common backends components like databases and message queues, and let you drive them from a convenient TypeScript business logic layer

APACHE-2.0 License

Downloads
302
Stars
1.1K
Committers
21

Bot releases are hidden (Show)

chiselstrike - ChiselStrike 0.15.0 Latest Release

Published by penberg almost 2 years ago

chiselstrike - ChiselStrike 0.14.0

Published by penberg almost 2 years ago

ChiselStrike 0.14.0 has been released!

For a Getting Started guide, please check: out https://docs.chiselstrike.com/tutorials/getting-started/

Release highlights:

✨ Kafka event publishing support (preview). There's now a publishEvent API that publishes events to a Kafka topic. For example, an endpoint that receives Github webhook notifications could use the publishEvent API to publish to Kafka as follows:

import { publishEvent } from "@chiselstrike/api";

 export default async function (req: Request) {
    // Parse Github webhooks JSON.
     const event = await req.json();
     const repository = event["repository"]["full_name"];
     const pusher = event["pusher"]["name"];
     const head = event["head_commit"]["id"];
     const deploymentEvent = {
         pusher,
         head,
     };
     // Publish the event to a Kafka topic:
     await publishEvent({
         topic: "deployment",
         key: repository,
         value: JSON.stringify(deploymentEvent),
     });
     return new Response("ok");
 }

For more information, check out the work-in-progress example application at https://github.com/chiselstrike/chiselstrike-examples/pull/13.

✨ Improvements to the query API to provide a MongoDB-like syntax for writing more complex restrictions. For example, you can now express filtering using the following syntax:

Person.cursor().filter({
    $and: [
        {
            $or: [
                {firstName: "Jan"},
                {firstName: "Pekka"}
            ]
        },
        {age: {$gte : 20, $lte: 50}}
    ]
})

✨TypeScript policies (preview) that allow you to specify rules on data creation, access, and filtering in TypeScript to build systems that comply with your business data rules. For more information, see the blog post on TypeScript policies at: https://blog.chiselstrike.com/why-middleware-may-not-be-the-right-abstraction-for-your-data-policies-daf8a0c2172f

🛠 Upgrade to Deno v1.26.2

chiselstrike - ChiselStrike 0.13.2

Published by penberg almost 2 years ago

ChiselStrike 0.13.2 has been released.

For a Getting Started guide, please check: out https://docs.chiselstrike.com/tutorials/getting-started/

Release highlights:

🛠 Add a --secrets-polling-period-s TIME option to chiseld that can be used to reduce polling load on some systems.

chiselstrike - ChiselStrike 0.13.1

Published by penberg almost 2 years ago

ChiselStrike 0.13.1 has been released.

For a Getting Started guide, please check: out https://docs.chiselstrike.com/tutorials/getting-started/

Release highlights:

🐛 Don't fail server startup if the events directory is missing.

🐛 Make create-chiselstrike-app generate an events directory with .gitkeep.

chiselstrike - ChiselStrike 0.13.0

Published by penberg almost 2 years ago

ChiselStrike 0.13.0 has been released.

For a Getting Started guide, please check: out https://docs.chiselstrike.com/tutorials/getting-started/

Release highlights:

🐛 Fix Node.js compatibility issues. Many npm packages such as Axios resulted in errors such as Error: Dynamic require of "buffer" is not supported on ChiselStrike. The problem is now fixed with Deno's Node polyfills imported into the ChiselStrike runtime.

✨ The routing API has been improved. There's now a RouteMap API that supports path-based parameters and allows you to specify routes by HTTP method.

For example, the following creates GET routes / for fetching all books and /:id for fetching a book with a specific ID, and a POST route / for creating books:

// models/Book.ts
import { ChiselEntity } from '@chiselstrike/api';

export class Book extends ChiselEntity {
    author: string;
    title: string;
}
// routes/books.ts
import { ChiselRequest, RouteMap } from '@chiselstrike/api';
import { Book } from '../models/Book.ts';

export default new RouteMap()
   .get('/', getAllBooks)
   .get('/:id', getOneBook)
   .post('/', postBook);

async function getAllBooks(): Promise<Book[]> {
   return await Book.findAll();
}

async function getOneBook(req: ChiselRequest): Promise<Book | undefined> {
   const id = req.params.get('id');
   return await Book.findOne({ id });
}

async function postBook(req: ChiselRequest): Promise<Book> {
   return await Book.create(await req.json());
}

✨ The CRUD API has also been revamped. Example:

// routes/books.ts
import { crud } from '@chiselstrike/api';
import { Book } from '../models/Book.ts';

export default crud(Book, {write: false});

Id<Type> type for lazy relationships. Example:

import { ChiselEntity, Id } from "@chiselstrike/api";

export class Author extends ChiselEntity {
    name: string;
}
export class Book extends ChiselEntity {
    title: string;
    author: Id<Author>;
}
const trial = await Book.findOne({title: "The Trial"});
const author = await Author.byId(trial!.author);

ChiselCursor has a count() function for count aggregations.

✨ Entities now support the Date data type.

✨ Feature preview of TypeScript policies.

✨ Deno upgraded to v1.25.4.

✨ The create-chiselstrike-app tool now generates a Dockerfile for building Docker images of your ChiselStrike application. This is useful for deploying ChiselStrike applications to Kubernetes, Fly.io, and others yourself.

🛠 The runtime has had significant re-work under the hood, which is a pre-requisite for improving stability and performance.

chiselstrike - ChiselStrike 0.12.1

Published by penberg about 2 years ago

ChiselStrike 0.12.1 has been released with the following changes:

✨ New experimental ChiselEntity.upsert API.

🐛 Fix an issue with entities being unusable in event handlers (https://github.com/chiselstrike/chiselstrike/issues/1665).

🐛 Fix chisel dev not hot-reloading event handlers.

🐛 Fix create-chiselstrike-app to specify events in Chisel.toml (https://github.com/chiselstrike/chiselstrike/issues/1664).

🚨 Token authentication only_for_verbs configuration option changed to only_for_methods. This is a breaking change from 0.12.0.

chiselstrike - ChiselStrike 0.12.0

Published by penberg about 2 years ago

ChiselStrike 0.12.0 has been released!

If you are new to ChiselStrike, you can create your own project with:

npx create-chiselstrike-app <project-name>

and then start the ChiselStrike runtime in development mode with:

npm run dev

For more information, see https://docs.chiselstrike.com/. Please report bugs, give feedback, and ask questions on our Discord or here on Github!


✨ Experimental streaming support. You can now implement Kafka/Redpanda consumers like you implement endpoints. Just drop a file with the same name as a topic in the events folder, and your application will start consuming messages from the topic:

import { ChiselEvent } from "@chiselstrike/api";

function toJSON(buffer: ArrayBuffer) {
    return JSON.parse(String.fromCharCode.apply(null, new Uint8Array(buffer)));
}

export default async function (event: ChiselEvent) {
    console.log(toJSON(event.value));
}

For more information, see https://docs.chiselstrike.com/Intro/streaming.

✨ Entity definitions now support arrays with primitive types (bool, number, and string) as properties. For example, to define a BlogPost entity with an array of keywords, type:

export class BlogPost extends ChiselEntity {
    text: string = "";
    keywords: []string = [];
}

For more information, see https://docs.chiselstrike.com/Intro/first#arrays.

✨ CRUD supports the PATCH HTTP method now.

✨ Entities with no data can be evolved without restrictions, including deleting them. Glauber, need help with the rationale.

✨ The create-chiselstrike-app command now generates a README.md file and a better .gitignore.

✨ Improved debugging support. The --inspect-brk flag now suspends the ChiselStrike application once at startup (instead for every endpoint invocation), which makes it possible to use the inspector for heap profiling, for example.

For more information, see https://docs.chiselstrike.com/Intro/debugging.

✨ Token authentication support.

chiselstrike - ChiselStrike 0.11.1

Published by penberg about 2 years ago

ChiselStrike 0.11.1 has been released with the following bug fix:

🐛 Fix an issue with chisel apply not allowing you to add a new model and use it immediately (https://github.com/chiselstrike/chiselstrike/issues/1605)

chiselstrike - ChiselStrike 0.11.0

Published by penberg over 2 years ago

ChiselStrike 0.11.0 has been released!

If you are new to ChiselStrike, you can create your own project with:

npx create-chiselstrike-app <project-name>

and then start the ChiselStrike runtime in development mode with:

npm run dev

For more information, see https://docs.chiselstrike.com/. Please report bugs, give feedback, and ask questions on our Discord or here on Github!

Shout out to all the contributors and in particular to @notTJ, @NickHodges, @7flash, and @MarinPostma who made their first ChiselStrike contribution in this release! 🎉


✨ Endpoint handlers can now return an arbitrary type (not just Response as before), which improves developer ergonomics when writing endpoints:

type Person = {
     name: string;
     age: number;
 }

 export default async function() : Promise<Person> {
     return { "name": "Elsa", "age": 1 };
 }

✨ Add support for an "omit" transformation to label policies, which can be used to make ChiselStrike omit a field completely from results. For example, to configure a "pii" label to use the transformation, use the following in the policy YAML file:

labels:
  - name: pii
    transform: omit

✨ The runtime secrets API was revamped to support partial updates in preparation for supporting secrets on the hosted ChiselStrike platform.

🐛 Fix bug in handling entities that depend on other entities. For example,

// in `models/A.ts`
import { ChiselEntity } from "@chiselstrike/api"
import { B } from "./B.ts"

export class A extends ChiselEntity {
        b: B;
}

and

// in `models/B.ts`
import { ChiselEntity } from "@chiselstrike/api"

export class B extends ChiselEntity {
        field: string;
}

would result in Error: field type `B` is neither a built-in nor a custom type error. This bug has now been fixed. Please note that there's still an open issue on cyclic dependencies: https://github.com/chiselstrike/chiselstrike/issues/1448

🐛 Fix an issue of never unloading old modules after chisel apply. Fixes, for example, labels being used in multiple files: https://github.com/chiselstrike/chiselstrike/issues/1201

🐛 Fix SQLite locked bug when inserting and deleting in the same transaction: https://github.com/chiselstrike/chiselstrike/issues/1482

🐛 Make sure chiseld is killed when chisel dev terminates to avoid a UX issue where chisel dev failed to start again.

🐛 Fix various bugs in chiselc which affected filter splitting and invalid filter() calls.

🐛 Fix auto-indexing failure when filtering on the id property.

📚 Improve ChiselStrike installation instructions on Windows with WSL.

chiselstrike - ChiselStrike v0.10.0

Published by penberg over 2 years ago

ChiselStrike 0.10.0 has been released!

If you are new to ChiselStrike, you can create your own project with npx create-chiselstrike-app <project-name> and then start the ChiselStrike runtime with npm run dev. For more information, see https://docs.chiselstrike.com/. Please report bugs, give feedback, and ask questions on our Discord!

✨ The ChiselStrike runtime provides built-in NextAuth.js integration, which unlocks support for nearly 60 different OAuth providers, plus email and SMS authentication. Access to additional info from the provider (eg, GitHub teams). Enhanced security with JWTs and sophisticated session management. More control over login widgets.

✨ Filter by lambda with ChiselEntity.findMany(), ChiselCursor.filter(), and others is now automatically transformed to an efficient, deferred query. This means that you can write queries with plain TypeScript:

Person.findMany(person => name == 'foo');

and the ChiselStrike compiler and runtime transform the lambda into a query. (For those of you who are curious, you can see the transformation with the chiselc tool that ships with the ChiselStrike tarball.)

✨ Auto-indexing is now in feature preview. If you write a query using ChiselEntity.findMany() or other query methods, the ChiselStrike compiler infers predicates and notifies the ChiselStrike runtime that they are candidate indexes. Right now, if the auto-indexing feature is enabled in Chisel.toml file, the runtime just generates indexes for all the predicates. Next steps for this feature are to integrate indexing with a SLAs and — down the line — with a database profiler for runtime feedback.

ChiselCursor API improvements: sortBy, minBy, and maxBy. See the documentation for more information.

chiselstrike - ChiselStrike v0.9.0

Published by penberg over 2 years ago

ChiselStrike 0.9.0 has been released!

If you are new to ChiselStrike, you can create your own project with npx create-chiselstrike-app <project-name> and then start the ChiselStrike runtime with npm run dev. For more information, see https://docs.chiselstrike.com/. Please report bugs, give feedback, and ask questions on our Discord!

Highlights:

📚 The ChiselStrike documentation has been greatly improved! 📓 https://docs.chiselstrike.com

✨ The CRUD API now supports filtering, sorting, and paging out-of-the-box! 🚀

For example, given the following entity definition:

import { ChiselEntity } from "@chiselstrike/api"

export class BlogComment extends ChiselEntity {
    content: string = "";
    by: string = "";
}

and the following endpoint:

import { BlogComment } from "../models/BlogComment";

export default BlogComment.crud();

The ChiselStrike runtime now allows you to filter by entity properties using the .<property> query parameter:

curl -g localhost:8080/dev/comments?.by=Jack

You can also sort the results with sort query parameter, and perform paging with offset and limit. For more information, see the documentation.

✨ The ChiselCursor API now supports skip which can be, for example, used with take for paging when using the composable query API:

export default async function (req: Request) {
    const people = Person.cursor()
        .sortBy("name")
        .take(2)
        .skip(1);
    // ....
}

✨ The ChiselStrike runtime now supports OpenAPI 2.0 for endpoint introspection. 🔎

You can see the endpoints of a given version at <host>/__chiselstrike/introspect/<version>. For example, you’re developing locally with npm run dev, your endpoints can be seen at http://localhost:8080/__chiselstrike/introspect/dev:

{
  "swagger": "2.0",
  "info": {
    "title": "hello",
    "version": "1.0.0-41bc667c"
  },
  "paths": {
    "/dev/hello": {}
  },
  "definitions": {}
}

Note: if your project has been deployed on the ChiselStrike platform, the version is the same as your deployment branch. For example, if your deployment branch is main, your endpoints are visible at https://<your-project>.chiselstrike.io/__chiselstrike/introspect/main. The endpoints will also later appear in the web user interface.

♻️ Similar to CRUD GET endpoints, CRUD DELETE supports the same filtering logic for narrowing the scope of a delete. So for example to delete all BlogComments by Jack, you can do curl -X DELETE localhost:8080/dev/comments/?.by=Jack. At the same time, we have removed the option to use filter={...} parameter with deletes.

♻️ General ChiselStrike runtime improvements around transactions and query execution to improve stability.

Package Rankings
Top 10.43% on Npmjs.org
Badges
Extracted from project README
Build Status License Discord Twitter