1.0.13 • Published 7 years ago

actionsuperhero v1.0.13

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

ActionSuperHero

Typescript decorators for working with actionhero framework.

Getting Started

npm install actionsuperhero

Setup Typescript compiler

Alter tsconfig.json to support decorators and emit node modules (unlike ES6 modules)

"compilerOptions": {
        "module": "none",
        "target": "es6",
        "noImplicitAny": true,
        "inlineSourceMap": true,
        "noImplicitReturns": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "outDir": "dist",
        "sourceRoot": "src",
        "moduleResolution": "node"
    }

Config action path

Edit config/api.js and add the following to the paths array

paths: [
...
'superObjects': [path.join(__dirname, '/../dist')]
...
],

Setup initializer

Create a file actionsuperhero.js under the initializers directory of your actionhero project, with the following content

'use strict'

const actionsuperhero = require("actionsuperhero");

actionsuperhero.setupInitializer(module);

Hello World Action

Create a file HelloWorld.ts under the src directory with the following content

import {Action, Api, ChainedFunction, IAction, IActionRequestData, Input} from "actionsuperhero";

@Action({
    actionName: "helloworld",
    description: "Just says hello world",
})
@Input({
    name: "user",
    required: false,
})
@Route({
    path: "helloworld",
    method: "get",
})
export class HelloWorld implements IAction {
    public run(api: Api, data: IActionRequestData, next: ChainedFunction): void {
        const name = data.params.user || "World";
        data.response.message = `Hello ${name}`;
        next();
    }
}
1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago