donau
v0.3.4
Published
Donau is a simple and lightweight REST API framework for Node.js. It is built on top of Express.js and provides a set of decorators to simplify the development of REST APIs.
Downloads
252
Readme
donau (REST API framework)
a lightweight framework for defining and running REST APIs. It is based on express and automatically generates and serves an open api documentation.
features
- usable as standalone server or with existing
express
- automatic Open API documentation generation/serving
- authentication handling
- simple and sleek developer experience (simmilar to Open API)
usage
check out the example project at /example
minimal_example
provides a rudimentary API serving just one endpointauth_example
provides a more complex API that defines nested endpoints and handles user authentication
simple example
an api can be defined and served just by:
defining the routes:
const routes: DonauRoute[] = [
route("/hello/{greeting}", {
description: `A simple hello world route`,
parameters: [
parameterPath("greeting", {
description: "the greeting phrase",
}),
],
worker: (greeting) => {
return greeting === "bye"
? err.badRequest("don't say bye");
: {message: `${greeting}, my friend!`};
},
}),
];
and then configuring the API
donauServerRun(1235 /* the port */, {
info: {
title: "basicAPI",
version: "1.0.3",
description: "an example API",
},
routes: routes,
});
contribution
you are most welcome to suggest improvements or contribute code via the github repository
I hope this package is useful to you, Yours, Robin