0.0.5 • Published 9 months ago
astropress v0.0.5
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:
- Attach Middlewares properly.
- Adding Child Routes.
- Customize the Context Object.
- 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,