New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

parse-cloud-kit

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-cloud-kit

Parse Server Cloud Code Kit

latest
npmnpm
Version
0.1.3
Version published
Maintainers
0
Created
Source

parse-cloud-kit

A toolkit for working with cloud code.

parse-cloud-kit is a utility to modularize and manage Parse Server Cloud Code more efficiently. It lets you organize Cloud Code in separate modules, each containing handlers for functions, triggers, and DI (listeners support is under development).

Installation

npm install parse-cloud-kit class-validator reflect-metadata tsyringe

Usage

Bootstrap your modules in your main cloud file:-
import bootstrap from 'parse-cloud-kit';
import { Module1, Module2 } from './modules';

bootstrap([Module1, Module2]);
Creating modules:-
@parseModule({
   handlers: [ Handler1 ]
})
class Module1 {}
Creating handlers:-
@injectable()
class Handler1 {
    @ParseFunction()
    async testFunc( @Req() req: Request, @CurrentUser() user: Parse.User ) {}
       
    @ParseTrigger({
        type: 'beforeSave',
        className: 'Post'
    })
    async onBeforeSavePorst( @CurrentUser() user: Parse.User, @RequestObject() object: Parse.Object ){}
    
    @ParseTrigger({
        type: 'beforeLogin',
    })
    async onBeforeLogin( @CurrentUser() user: Parse.User, @RequestObject() object: Parse.Object ){}
    
    @ParseTrigger({
        type: 'beforeSaveFile',
    })
    async onBeforeSaveFile( @CurrentUser() user: Parse.User, @RequestObject() object: Parse.Object ){}
}

Easy validation:- validation class:-

import { IsString } from 'class-validator';

class LogEvent () {
    @IsString()
    name!: string;
}

Handler:-

@injectable()
class Handler1 {
    @ParseFunction()
    async testFunc( @Params() data: LogEvent ) {}
}

When the function is called, it would run class-validator validations and throw error when the validation fails.

DI:-

As all the handlers are injetable, we can create custom classes (eg. service/repository classes ) as injectable and import them in handlers.

import { injectable } from 'tsyringe';

@injectable()
class SomeService () {
    async heper(){}
}

Handler:-

@injectable()
class Handler1 {
    constructor(
       @inject(SomeService)
       private readonly someService: SomeService
    ){}

    @ParseFunction()
    async testFunc( @Params() data: LogEvent ) {
        this.someService.helper();
    }
}

License

MIT

Keywords

parse

FAQs

Package last updated on 26 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts