Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/domin-mnd/storona
🛣️ Simple opinionated file-based routing for JavaScript applications.
https://github.com/domin-mnd/storona
backend express fastify router
Last synced: about 1 month ago
JSON representation
🛣️ Simple opinionated file-based routing for JavaScript applications.
- Host: GitHub
- URL: https://github.com/domin-mnd/storona
- Owner: domin-mnd
- License: mit
- Created: 2024-08-28T14:18:09.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-09-17T14:13:19.000Z (2 months ago)
- Last Synced: 2024-09-28T11:22:15.950Z (about 2 months ago)
- Topics: backend, express, fastify, router
- Language: TypeScript
- Homepage: https://storona.domin.pro/
- Size: 359 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
![Preview banner](public/preview-banner.png)
JavaScript backend applications tend to rely on a framework or meta-framework to handle routing and architecture. But for specific use cases in which a full framework is not necessary, developers usually have to build their own routing system from scratch or using a full-fledged wrapper. This is usually a time-consuming process that can be avoided.
For this reason, Storona was created. It is designed to be easy to use and easy to understand, with a minimal learning curve.
Here's a quick example of how to use Storona:
```js
const express = require("express");
const { createRouter } = require("storona");const app = express();
createRouter(app, {
directory: "src/routes",
// Set to true to use the package version. 1.0.0 -> /v1
prefix: "/v1/api",
quiet: false,
});app.listen(3000, async () => {
console.info("API running on port 3000");
});
```#### Result
```
.
└─ src
├─ routes
│ ├─ directory
│ │ ├─ [fruit].get.js --> GET /v1/api/directory/:fruit
│ │ └─ index.put.mjs --> PUT /v1/api/directory
│ ├─ apple.post.ts --> POST /v1/api/apple
│ └─ index.get.jsx --> GET /v1/api
└─ index.js
```## Philosophy
Storona is designed to be simple and easy to use. It is neither a complete framework nor a package for certain framework. The goal is to unify simple architecture to something that everyone can understand and use.
The idea of route design was highly inspired by the [Nitro](https://nitro.unjs.io/guide/routing#filesystem-routing) framework that uses h3 under the hood. Storona on the other hand is compatible with the following frameworks: Express, Fastify.
For the simplicity reason Storona supports TypeScript and JSX out-of-the-box. The transpilation of routes is handled by [tsup](https://tsup.egoist.dev/).
> Use `compilerOptions.jsx` in your `tsconfig.json` to change the transpilation behavior of JSX/TSX.
## Limitations
Due to some [characters being forbidden in Windows file names](https://stackoverflow.com/a/31976060/14301934), Storona may not provide full set of features of the underlying framework's route registration.
To avoid this problem, you can override the route by using the `route` exported variable in the route file. To know more about this, see the [Templates](https://storona.domin.pro/guide/routing/templates#overriding-route-and-method) guide.
## Documentation
For more information regarding Storona, please refer to the [official documentation](https://storona.domin.pro).