Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deno): Feathers for Deno core build #2299

Merged
merged 5 commits into from
Apr 21, 2021
Merged

feat(deno): Feathers for Deno core build #2299

merged 5 commits into from
Apr 21, 2021

Conversation

daffl
Copy link
Member

@daffl daffl commented Apr 10, 2021

This pull request adds a Feathers core build for Deno (#1964), a secure runtime for JavaScript and TypeScript applications. Just like NodeJS, the browser or React Native it is another runtime that Feathers now supports and will also provide a server side (HTTP and Websocket) transport for. To my knowledge, this will make it the first web framework to run on both platforms. Why reinvent the wheel for things that are working well?

Why Deno?

Deno is interesting for Feathers for the following reasons:

  • TypeScript built-in
  • Secure by default. Filesystem, networking and other access needs to be allowed explicitly 🔑
  • Module references by URLs. No heavy npm installs, package.json or module installations scripts. This makes deployments significantly faster and easier. Just tell a Deno VM the URL to your main module your app will start up. 🚀
  • Tighter WASM integration could eventually allow to write services in other languages like Rust or Java and expose them through Feathers as a high-performance API (how cool is that?) 🤩

It is also allows kind of a "Back To the Basics" for the lightweight nature that Feathers always had. For some reason it seems that all the available ORM and database integrations have made it look much more heavy and limited than it actually is. With Deno you will (for now) write your own services from scratch just like you would do with any other middleware based framework and Feathers will do what it does best which is provide you with the API layer (including the client!).

Usage

This pull request specifically focussed the core module which - once published - can be used like this:

// app.ts
import { feathers } from 'https://deno.land/x/[email protected]/mod.ts';

type Message {
  message: string;
}

class MyService {
  async create (data: Message) {
    return data;
  }
}

type ServiceTypes {
  myservice: MyService
}

const app = feathers<ServiceTypes>();

app.use('myservice', new MyService());

app.service('myservice').on('created', (data: Message) => {
  console.log('Created', data);
});

await app.service('myservice').create({
  message: 'Hello from Deno'
});

Currently it also still needs a tsconfig.json with strictNullChecks: false:

{
  "compilerOptions": {
    "strictNullChecks": false
  }
}
$ deno run --config tsconfig.json app.ts

@daffl daffl merged commit dece8fb into dove Apr 21, 2021
@daffl daffl deleted the deno branch April 21, 2021 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant