@anodized/http
v1.0.16
Published
A decorator driven IoC backend framework aimed at keeping your codebase clean and reducing complexity
Downloads
23
Maintainers
Readme
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.