Build serverless Node.js microservices fast
This project is under heavy development.
Campkit is an opinionated Node.js framework for building serverless microservices. It makes a bunch of decisions so that you don't have to. Currently it works best with aws lambda and the serverless framework.
npx @campkit/cli create someServiceName
import { RestController, Get, Post } from "@campkit/rest";@RestController({ basePath: "/user" }) export class UserController {
@Get({ path: "/:id" // -> GET user/1234 }) getUserById({ params }) { return { id: params.id }; }
@Post({ path: "/" // -> POST user/ }) createUser({ body }){ return { user: body }; }
// index.jsimport { CampkitFactory } from "@campkit/core"; import { UserApp } from "./user.app";
export const handler = async (event, context) => { return await CampkitFactory.create(UserApp, { event, context }); };
// user.app.jsimport { App } from "@campkit/core"; import { UserController } from "./user.controller";
@App({ name: "user", restController: UserController }) export class UserApp {
}
// user.controller.jsimport { RestController, Get, Post } from "@campkit/rest";
@RestController({ basePath: "/user" }) export class UserController {
@Get({ path: "/:id" // -> GET user/1234 }) getUser({ params }) { return { message: "get user by id", id: params.id }; }
@Post({ path: "/" // -> POST user/ }) createUser({ body }){ return { message: "create a user", userInfo: body }; }