Unicorn-web is a bun based web framework which makes the process of creating a web application much simpler. It provides core HTTP entities to simplify and standardize the HTTP requests handling operations by offering a convenient way to setup a server, define routes and extract relevant information from the requests. It aims to be a fast, highly customizable and scalable web framework that helps you in your daily tasks, providing common functionality abstractions, improve code readability and maintainability.
bun add @unicorn.web/core
Let's create your first unicorn.app
- Open your
index.ts
and creates a new server instance:
import { UnicornServer } from '@unicorn.web/core'
const server = new UnicornServer();
- Add some routers to fetch requests:
import { UnicornServer } from '@unicorn.web/core'
const server = new UnicornServer();
server.get('/foo', () => new Response('foo'));
server.post('/boo', (ctx) => new Response(`Hi, ${ctx.body.name}`));
- Serve the application in a port of your choice:
import { UnicornServer } from '@unicorn.web/core'
const server = new UnicornServer();
server.get('/foo', () => new Response('foo'));
server.post('/boo', (ctx) => new Response(`Hi, ${ctx.body.name}`));
server.serve(3000);
- Start the server
bun run index.ts
Just four lines and you have a working web application. Now, your app is running at http://localhost
in the port you previously setup. If you make get requests for http://localhost:3000/foo
it will receive foo
back and if you make post requests for http://localhost:3000/boo
you receive Hi
and the name you sent in the body back.
Contributions are always welcome! Please follow these steps:
-
Fork the project repository.
-
Create a new branch with a descriptive name (e.g.,
new-feature-branch
orbugfix-issue-123
).
git checkout -b new-feature-branch
- Commit your changes with a clear commit message that explains the changes you've made.
git commit -m 'Implemented new feature.'
- Push your changes to your forked repository
git push origin new-feature-branch
- Create a new pull request describing the changes you've made and why they're necessary.
The project maintainers will review your changes and provide feedback or merge them into the main branch.
This project is licensed under the MIT License. See the LICENSE file for additional info.