vovk
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

vovk
REST for Next

Transforms Next.js into a powerful and extensible REST API platform.
Made with TypeScript, inspired by NestJS.

Website     Documentation     Interactive Examples     vovk-zod     vovk-hello-world     vovk-react-native-example

npm version  TypeScript  Build status


Example back-end Controller Class:

import { get, prefix } from 'vovk';

@prefix('hello')
export default class HelloController {
  /**
   * Return a greeting from 
   * GET /api/hello/greeting
   */
  @get('greeting')
  static getHello() {
    return { greeting: 'Hello world!' };
  }
}

Example component that uses the auto-generated client library:

'use client';
import { useState } from 'react';
import { HelloController } from 'vovk-client';
import type { VovkClientReturnType } from 'vovk';

export default function Example() {
  const [
    serverResponse, setServerResponse,
  ] = useState<VovkClientReturnType<typeof HelloController.getHello>>();

  return (
    <>
      <button
        onClick={async () => {
          setServerResponse(
            await HelloController.getHello()
          );
        }}
      >
        Get Greeting from Server
      </button>
      <div>{serverResponse?.greeting}</div>
    </>
  );
}

Readme

Keywords

Package Sidebar

Install

npm i vovk

Weekly Downloads

34

Version

1.1.5

License

MIT

Unpacked Size

172 kB

Total Files

52

Last publish

Collaborators

  • finom