8000 GitHub - n4ze3m/voll-js
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

n4ze3m/voll-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Volljs

WARNING: This is a work in progress and is not ready for production use.

A simple, file-based HTTP framework using Bun as a runtime.

Current Features

  • File-based routing
  • Built-in middleware support
  • Schema validation using Ajv
  • TypeScript support

Installation

bun add volljs

Quick Start

Project Structure

your-project/
├── routes/
│   ├── index.ts         # GET /
│   ├── users/
│   │   ├── index.ts     # GET /users
│   │   ├── [id].ts      # GET /users/:id
│   │   └── create.ts    # POST /users/create
│   └── posts/
│       └── [slug].ts    # GET /posts/:slug
├── package.json
└── index.ts

Basic Usage

Create your entry file index.ts:

import { Voll } from 'volljs'

const app = new Voll({
  routesDir: 'routes',
  showRoutes: true
})

app.listen(3000)

Next, create a route file routes/index.ts:

import { VollRequest, VollResponse } from 'volljs'

export const GET = (req: VollRequest, res: VollResponse) => {
  return res.sendJson({ message: 'Welcome to Voll!' })
}

Create a dynamic route routes/users/[id].ts:

import { VollRequest, VollResponse } from 'volljs'

export const GET = (req: VollRequest, res: VollResponse) => {
  const { id } = req.params
  return res.sendJson({ userId: id })
}

// Add schema validation
export const config = {
  GET: {
    schema: {
      params: {
        type: 'object',
        properties: {
          id: { type: 'string' }
        },
        required: ['id']
      }
    }
  }
}

Start the server

bun run index.ts

Visit http://localhost:3000 to see your API in action!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0