9ight

0.0.0-canary.6 • Public • Published

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;
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i 9ight

Weekly Downloads

7

Version

0.0.0-canary.6

License

MIT

Unpacked Size

88.8 kB

Total Files

213

Last publish

Collaborators

  • maxchehab