Skip to content

Uvacoder/nuxt-nitro-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nuxt-nitro-helpers

Install

Install package:

yarn add nuxt-nitro-helpers
# or
npm install nuxt-nitro-helpers

Usage

// ./servers/api/posts.ts

import { useRoute } from "nuxt-nitro-helpers";

export default useRoute({
  get() {
    return "GET /posts";
  },

  post(_, res) {
    res.statusCode = 201;
    return "POST /posts";
  }
});
// ./servers/api/me.ts

import { useGetRoute } from "nuxt-nitro-helpers";

export default useGetRoute(() => {
    return "GET /me";
});
// ./servers/api/quotes.ts

import { useRoute } from "nuxt-nitro-helpers";

export default useRoute({
  get() {
    return "GET /quotes";
  },

  fallback(_, res) {
    res.statusCode = 405;

    return "Method Not Allowed";
  },
});

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published