@wtprograms/mvc
TypeScript icon, indicating that this package has built-in type declarations

1.0.30 • Public • Published

mvc

mvc provides an very simplified MVC framework similar to that of .NET Core MVC.

Index

Installation

Installation

npm install --save @wtprograms/mvc

Usage

import {
  WebHostBuilder,
  DEFAULT_COLOR_MAPS,
  ConsoleLoggerProvider,
  FileLoggerProvider,
  IStartup,
  ControllerRoute,
  HttpGet,
  HttpPost,
  Model,
  HttpDelete
} from '@wtprograms/mvc';

@ControllerRoute('/values')
class ValuesController {
  @HttpGet()
  get() {
    return ['value1', 'value2'];
  }

  @HttpGet('/:id')
  getSingle(id: number) {
    return 'value';
  }

  @HttpPost()
  post(@Model() value: string) {}

  @HttpDelete('/:id')
  delete(id: number) {}
}

class Startup implements IStartup {
  configure(context: ApplicationContext) {
    context.loggerFactory.loggingLevel = LogLevel.debug;
    context.loggerFactory.providers.push(
      new ConsoleLoggerProvider(DEFAULT_COLOR_MAPS)
      new FileLoggerProvider('./app.log'));

    context.controllers.push(ValuesController);
  }
}

new WebHostBuilder()
  .useStartup(Startup)
  .build()
  .run(5000);

Readme

Keywords

Package Sidebar

Install

npm i @wtprograms/mvc

Weekly Downloads

1

Version

1.0.30

License

ISC

Unpacked Size

108 kB

Total Files

174

Last publish

Collaborators

  • willemtoerien