Skip to content
Build serverless Node.js microservices fast
TypeScript JavaScript
Branch: master
Clone or download
Latest commit 6f7e9a7 Oct 25, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github adding contribute readme Oct 8, 2019
packages chore(release): publish Oct 25, 2019
scripts repo level scripts Oct 25, 2019
.gitignore no message Oct 10, 2019
.prettierignore no message Oct 10, 2019
.prettierrc no message Oct 10, 2019
LICENSE adding license Oct 8, 2019
README.md Update README.md Oct 25, 2019
lerna.json lerna Oct 10, 2019
package.json no message Oct 10, 2019
yarn.lock repo level scripts Oct 25, 2019

README.md

⛺ Campkit

Build serverless Node.js microservices fast.


serverless node awesome

Intro

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.

Quick start

npx @campkit/cli create someServiceName

Features

  • small & simple
  • define your service as a class annotating it to provide configuration
  • path and query parameters are automatically injected into the class method
  • service discovery built in (coming soon)

Works with provider

  • Amazon Web Service - Lambda

At a glance

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
    };
  }

Basic microservice

// index.js

import { CampkitFactory } from "@campkit/core";
import { UserApp } from "./user.app";

export const handler = async (event, context) => {
  return await CampkitFactory.create(UserApp, { event, context });
};
// user.app.js

import { App } from "@campkit/core";
import { UserController } from "./user.controller";

@App({
  name: "user",
  restController: UserController
})
export class UserApp {

}
// user.controller.js

import { 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
    };
  }
You can’t perform that action at this time.