Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/getcampsite/campkit
Build serverless Node.js microservices fast
https://github.com/getcampsite/campkit
campkit lambda nodejs serverless serverless-microservices
Last synced: 3 months ago
JSON representation
Build serverless Node.js microservices fast
- Host: GitHub
- URL: https://github.com/getcampsite/campkit
- Owner: getcampsite
- License: mit
- Created: 2019-10-05T13:58:15.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T10:24:20.000Z (almost 2 years ago)
- Last Synced: 2024-04-25T13:43:17.244Z (7 months ago)
- Topics: campkit, lambda, nodejs, serverless, serverless-microservices
- Language: TypeScript
- Homepage:
- Size: 1.3 MB
- Stars: 125
- Watchers: 5
- Forks: 8
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-js-posts - Campkit: A Framework for Building Node.js Microservices Faster
README
⛺ Campkit
Build serverless Node.js microservices fast.
[![serverless](http://public.serverless.com/badges/v3.svg)](https://serverless.com)
[![node](https://img.shields.io/badge/node-%3E%3D%2010.0.0-brightgreen)](https://nodejs.org)
[![awesome](https://img.shields.io/badge/stars-%E2%98%85%E2%98%85%E2%98%85%E2%98%85%E2%98%85-brightgreen)](https://github.com/getcampsite/campkit)## 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
```sh
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
- [x] Amazon Web Service - Lambda
## At a glance
```js
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
```js
// index.jsimport { CampkitFactory } from "@campkit/core";
import { UserApp } from "./user.app";export const handler = async (event, context) => {
return await CampkitFactory.create(UserApp, { event, context });
};
``````js
// user.app.jsimport { App } from "@campkit/core";
import { UserController } from "./user.controller";@App({
name: "user",
restController: UserController
})
export class UserApp {}
``````js
// 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
};
}
```