GithubHelp home page GithubHelp logo

excoriate / campkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from getcampsite/campkit

0.0 2.0 0.0 276 KB

Build serverless Node.js microservices fast

License: MIT License

TypeScript 75.49% JavaScript 24.51%

campkit's Introduction

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

campkit's People

Contributors

roger-rodriguez avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.