Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robinnaumann/donau
https://github.com/robinnaumann/donau
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/robinnaumann/donau
- Owner: RobinNaumann
- Created: 2024-06-21T20:31:03.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-09-01T11:24:52.000Z (4 months ago)
- Last Synced: 2024-12-18T04:59:46.203Z (25 days ago)
- Language: TypeScript
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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 endpoint
- `auth_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:
```typescript
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
```typescript
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](https://github.com/RobinNaumann/donau)
_I hope this package is useful to you,_
_Yours, Robin_