9ight

A Next.js API framework

Usage no npm install needed!

<script type="module">
  import ight from 'https://cdn.skypack.dev/9ight';
</script>

README

9ight 🌒

A Next.js API framework

yarn add 9ight next
// pages/api/users.ts

import { Body, Controller, Get, Params, Post } from '9ight';

const db = [];

@Controller('users')
export default class Users {

  @Get(':id')
  get(@Params() { id }) {
    return db[id];
  }

  @Patch(':id')
  update(@Body() body) {
    db[id] = Object.assign(db[id], body)
    return db[id];
  }

  @Post()
  create(@Body() body) {
    db.push({ id: db.length, name: body.name });
    return db.slice(-1)
  }

  @Get()
  list() {
    return db;
  }
}