0.0.5 • Published 9 months ago

astropress v0.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

Astropress

a plugin for Astro to create api endpoints

NOTE: Under Development, Find any bugs open a ticket or fork and create a PR.

Plugin Config

import { defineConfig } from "astro/config";
import vercel from "@astrojs/vercel/serverless";
import { astroPress } from "astropress";

// https://astro.build/config
export default defineConfig({
  integrations: [
    astroPress({
      pattern: "/routes/[...dynamic]",
      entryPoint: "./src/api/index.ts",
    }),
  ],
  output: "server",
  adapter: vercel(),
});

Create Endpoint:

import { APIContext, APIRoute } from "astro";
import { Router } from "astropress";
const router = new Router();
router.setBasePath("/routes");
router.get("/hello", () => {
  return new Response("Pong");
});

router.get("/user/:id", (ctx) => {
  console.log(ctx.params);
  return new Response("User");
});

export const all: APIRoute = (ctx: APIContext) => router.init(ctx as any);

RoadMap

Next Release:

  1. Attach Middlewares properly.
  2. Adding Child Routes.
  3. Customize the Context Object.
  4. Find a solution to make the response more fast.

Feature Request

Create a Ticket for new features.

Feel Free to contribute Fork , edit and Share,

0.0.5

9 months ago

0.0.4

9 months ago

0.0.31

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago