https://github.com/vixalien/feathers_oak
Feathers Oak framework bindings and REST provider
https://github.com/vixalien/feathers_oak
deno feathers oak
Last synced: 23 days ago
JSON representation
Feathers Oak framework bindings and REST provider
- Host: GitHub
- URL: https://github.com/vixalien/feathers_oak
- Owner: vixalien
- Created: 2022-08-04T15:27:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-29T08:49:58.000Z (over 2 years ago)
- Last Synced: 2025-03-06T07:11:41.639Z (about 2 months ago)
- Topics: deno, feathers, oak
- Language: TypeScript
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# feathers_oak
[Feathers](https://feathersjs.com) - [Oak](https://github.com/oakserver/oak) 🦕
framework bindings and REST provider. Oak works under both Deno and NPM.## Usage
`feathers_oak` requires 2 pre-existing `feathers` and `oak` apps. It just binds
them together so that you can use your services from oak as a REST endpoint with
oak.```ts
// Oak
import { Application } from "https://deno.land/x/oak/mod.ts";// Importing feathers
import { feathers } from "https://deno.land/x/feathers/mod.ts";
import {
errorHandler,
restRouter,
routing,
} from "https://deno.land/x/feathers_oak/mod.ts";// we will use mongo and it's feathers adapter as an example, but you can use whatever database adapter you like
import { MongoClient, ObjectId } from "https://deno.land/x/mongo/mod.ts";
import { MongoService } from "https://deno.land/x/feathers_mongo/mod.ts";// --- Services ---
// initialising the mongo client & service
const client = new MongoClient();
await client.connect("mongodb://127.0.0.1:27017");
const db = client.database("test");interface UserSchema {
_id: ObjectId;
username: string;
password: string;
age: number;
}const users = db.collection("users");
const Users = new MongoService({
// set the collection
Model: users,
// default pagination options
paginate: {
default: 10,
max: 50,
},
});// --- Feathers ---
// creating the feathers app
const app = feathers();
// IMPORTANT: must initialize routing before adding services
app.configure(routing() as any);
app.use("users", Users);// --- Oak ---
// creating the oak site & adding feathers REST router
const site = new Application();
const router = restRouter(app);
site.use(errorHandler());
site.use(router.routes(), router.allowedMethods());// start the site
site.listen({
post: 3000,
});
```NOTE: this project is WIP, and some things may not work or misbehave. This
README will be updated when this package reachs `v1`.