1.0.4 • Published 3 months ago

arky-js v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

Arky.js

Arky.js is a powerful annotation-based framework for building serverless applications using AWS Lambda and API Gateway. Inspired by Angular and NestJS, it simplifies development by providing decorators for defining modules, controllers, and services. The framework compiles your structured code into a Serverless Framework-compatible project, making deployment seamless.

Features

  • Annotation-based architecture (@Module, @Controller, @Get, @Post, etc.)
  • Dependency Injection for modules and services
  • Automatic Serverless Framework integration
  • Each controller is mapped to a separate Lambda function
  • CLI for easy deployment (arky deploy)

Installation

Install Arky.js globally or as a project dependency:

npm install -g arky-js  # Global install
# or
npm install arky-js --save  # Project install

Project Structure

An Arky.js project follows a structured module-based approach:

project-root/
├── src/
│   ├── app.module.ts
│   ├── modules/
│   │   ├── user/
│   │   │   ├── user.controller.ts
│   │   │   ├── user.service.ts
│   ├── main.ts
├── .sfd/  # Compiled serverless files
├── package.json
├── tsconfig.json
└── README.md

Example Code

1. Defining a Module

import { Module } from "arky-js";
import { UserController } from "./user.controller";
import { UserService } from "./user.service";

@Module({
  controllers: [UserController],
  providers: [UserService],
})
export class UserModule {}

2. Creating a Controller

import { Controller, Get, Post } from "arky-js";
import { UserService } from "./user.service";

@Controller("/users")
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Get("/")
  getAllUsers() {
    return this.userService.getUsers();
  }

  @Post("/")
  createUser() {
    return this.userService.createUser();
  }
}

3. Implementing a Service

import { Injectable } from "arky-js";

@Injectable()
export class UserService {
  private users = [{ id: 1, name: "John Doe" }];

  getUsers() {
    return this.users;
  }

  createUser() {
    const newUser = { id: Date.now(), name: "New User" };
    this.users.push(newUser);
    return newUser;
  }
}

CLI Commands

Arky.js provides a command-line interface (CLI) for managing your serverless application.

Initialize a new project

arky init my-project

Compile project into Serverless-compatible format

arky build

Deploy the project to AWS

arky deploy

This will generate a .sfd package and trigger the serverless deploy command.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Future Improvements

  • Support for WebSockets and GraphQL
  • Middleware and Authentication support
  • Plugin system for extending Arky.js functionality

Contributions are welcome! 🚀