Develop Web Applications The Way You Like!

Cargo focuses on best in class development experience. The right abstraction of helpful features and freedom for flexibility, are the core principles of Cargo. — Together with Deno as a runtime and Typescript, you get the right toolbox to deliver fast and secure applications, right from the beginning.

Heads up! Cargo is currently in development.

It's not ready for production use yet. There are still some things to do, until version 1 is released. Public APIs need to be fixed and all features need to be tested.

But you can help, take a test ride and give feedback.

Expandable For Your Needs

Cargo Core

Flexible and adaptable core framework for web applications and services.

Preview

Cargo Inspect

Schema definition and validation with meaningful error infomation.

Beta

Cargo Auth

Auth framework based on strategies inspired by Passport

Beta

Cargo Parcel

Server side rendering and dynamic frontend components with JSX.

In development

Cargo Load

Command Line Interface for managing Cargo applications.

In development

Cargo Pick

Transform and handle Promise results.

In development

Cargo Assemble

Dependency injection and management for your Cargo application

Coming soon

Cargo Depot

ORM integration for your Cargo application based on Prisma.

Coming soon

From Zero to Hello world!

The following example assumes that a current Deno version is installed on the system. The complete example can be viewed and downloaded from the Examples.

1

Register Route and Request Handler

Routes can be easily created and registered, in the application, with the route creation functions: Get(), Post(), Put(), Patch() and Delete()

These functions accept a path segment and a route handler function as parameters. The handler function receives the current request context as an input.

2

Return Response

As soon all tasks in the request handler are finished a Response() should be returned to the client.

Cargo uses the official Web APIs where possible. The Response() object is one example. More detailed information can be found in the Web API documentation

3

Apply middleware functions

Optionally multiple middleware can be applied. Middleware allows to do tasks before and after the route handler is executed.

4

Bootstrap and Run the Application

Last but not least, the application is ready for bootstrapping and can be started with the run() function.

In the terminal start the application with deno run --allow-net --allow-read hello-world.ts

import { bootstrap } from "https://deno.land/x/cargo/mod.ts";
import { Get } from "https://deno.land/x/cargo/http/mod.ts";
import { logTimeToResponse } from "https://deno.land/x/cargo/middleware/mod.ts";

interface MessageParams {
  message: string;
}

/*
 * 1. Register Route and Request Handler
 */
Get("/:message", ({ params }) => {

  /*
   * 2. Return Response
   */
  return new Response((<MessageParams>params).message);
})

/*
 * 3. Apply middleware functions (optional)
 */
.middleware(logTimeToResponse);

/*
 * 4. Bootstrap and Run the Application
 */ 
(await bootstrap()).run();

Included in the gift box

Flexible Route Handling

Routes can easily be registered in code with the route creation functions or auto-loaded from the /routes directory.

Organise Routes with Groups

Routes can be organised with Group(). This allows to prepend routes with path segment and apply middleware functions.

Transform with Middleware

Transform requests with middleware and apply tasks before or after route handling. Ideal for Auth, Validation and more.

Authentication with a Breeze

Secure endpoints and apply existing or custom strategies such as JWT, OAuth2, Password and more.

Secure Input Validation

Create schemas to automatically validate incoming request data, with meaningful error messages.

Automated Body Parsing

Cargo takes care of converting and parsing incoming request body data into the right type.

Dependency Injection Container

Simplify application dependency management with inversion of control and a configurable DI container. (Coming soon)

And more Feature to Come

  • Dynamic frontend components with JSX
  • Reliable config service
  • Realtime web-streams out of the box
  • ORM with support for migrations