Skip to content

maxchehab/9ight

Repository files navigation

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

About

🌒 A Next.js API framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published