@anodized/http
TypeScript icon, indicating that this package has built-in type declarations

1.0.16 • Public • Published

Anodized HTTP components

The HTTP components to the Anodized framework, built for complete modularity.

Installation

First, install the HTTP components

npm i @anodized/http

Next, create your entry script, in this example we'll say src/app.ts

import { AnodizedApp } from '@anodized/http';

AnodizedApp({
    httpPort: 8080,
    sourceDirectory: 'src/',
    runtimeType: 'node', // this is future-proofing for use in serverless environments such as AWS lambda.
    // optional extras,
    logger: {
        log: (value: string) => {},
        warn: (value: string) => {}
        error: (value: string) => {}
        exception: (value: string) => {}
    },
    plugins: [
        // lookup @anodized/tsx
    ],
    publicDirectories: [
        'public/'
    ],
    verbose: false, // defaults to false.
})

Now all your TypeScript components will be loaded fron the source directory. Next, create a controller, in lets say src/controllers/homepage.ts

import { Get, Controller, PreAuthorize } from '@anodized/http'

@Controller()
class Homepage
{
    @Get({ path: '/', produces: 'text/html' })
    showHomepage() {
        return '<h1>Hello World</h1>';
    }
    @Get({ path: '/about.html' })
    showAbout() {
        return '<h1>About me</h1>';
    }
}

Now, run your application and head to http://localhost:8080 to see your result. See the wiki for more in-depth examples.

Package Sidebar

Install

npm i @anodized/http

Weekly Downloads

17

Version

1.0.16

License

MIT

Unpacked Size

90.3 kB

Total Files

51

Last publish

Collaborators

  • hudson1998x