UNPKG

2.59 kBMarkdownView Raw
1[![Build Status](https://travis-ci.org/miter-framework/miter.svg?branch=master)](https://travis-ci.org/miter-framework/miter)
2
3# Miter Web Framework
4
5Miter is a web framework heavily influenced by [Ruby on Rails][rails] and [SailsJs][sails]. It is built on top of [Express][express]. Miter uses Typescript's experimental decorators to create elegant controllers and services, using dependency injection to avoid tight coupling.
6
7## Installation
8
9Install `miter` using NPM.
10
11```bash
12npm install --save miter miter-cli
13```
14
15`miter-cli` is optional, but can be used to generate and run database migrations from the command line. See [miter-framework/miter-cli][miter_cli] for more details.
16
17## Example
18
19First, create a controller:
20
21```typescript
22import { Controller, Get } from 'miter';
23import { Request, Response } from 'express';
24
25@Controller()
26class HelloWorldController {
27
28 @Get('greet')
29 async sampleRoute(req: Request, res: Response) {
30 res.status(200).send(`Hello, World!`);
31 }
32
33}
34```
35
36Next, start the Miter server using `Miter.launch`:
37
38```typescript
39import { Miter } from 'miter';
40import { HelloWorldController } from './hello-world.controller.ts';
41
42Miter.launch({
43 name: 'server-name',
44 port: 8080,
45 router: {
46 controllers: [HelloWorldController]
47 }
48});
49```
50
51After you have launched your server, navigate to [localhost:8080/greet](example_url) to see your route in action.
52
53This is a simple demonstration, but you can already see how simple and easy it is to get a server up and running.
54
55## Contributing
56
57Miter is a relatively young framework, and there are bound to be many ways that it can be improved. If you notice a bug, or would like to request a feature, feel free to [create an issue][create_issue]. Better yet, you can [fork the project][fork_miter] and submit a pull request with the added feature.
58
59## Changelog
60
61[See what's new][whats_new] in recent versions of Miter.
62
63## Attribution
64
65Special thanks to [BrowserStack][browserstack] for generously hosting our cross-browser integration tests!
66
67[![BrowserStack](./attribution/browser-stack.png)][browserstack]
68
69[rails]: http://rubyonrails.org/
70[sails]: http://sailsjs.com/
71[express]: https://expressjs.com/
72[miter_cli]: https://github.com/miter-framework/miter-cli
73[example_url]: http://localhost:8080/greet
74[create_issue]: https://github.com/miter-framework/miter/issues/new
75[fork_miter]: https://github.com/miter-framework/miter/pulls#fork-destination-box
76[whats_new]: https://github.com/miter-framework/miter/blob/master/CHANGELOG.md
77[browserstack]: https://www.browserstack.com