Skip to content

Commit c0ad5ad

Browse files
authored
Update README.md
1 parent b401f3d commit c0ad5ad

File tree

1 file changed

+80
-1
lines changed

1 file changed

+80
-1
lines changed

README.md

+80-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,80 @@
1-
# ProperJS
1+
## What is ProperJS?
2+
3+
ProperJS is a lightweight experimental Javascript Framework for the development of Backend services using modern features like IoC and Dependency Injection.\
4+
It is built in Typescript and support Multi Tier Layering thanks to features like `Controller` and `Component` (known also as View and Business Logic layers).\
5+
Most of the ideas and concepts are well known and based on famous projects like [NestJS](https://nestjs.com/) and [Spring](https://spring.io/).
6+
7+
## Main Goals
8+
One of the main goals of ProperJS is to bring a more generic framework that works in a `Context` like `Java Beans`, since Javascript is a interpreted programming language this goal is achieved with an old fashion directory scan that register all the components into the `ApplicationContext`.\
9+
Another goal is to let anyone learn how a modern MVC Framework works to help bring new idea into the community
10+
11+
## Quick Start
12+
Right now there isn't a public NPM package instead for the alpha and testing phase we use local modules features from Node, one example can be seen [here](examples/hello-word-example).\
13+
ProperJS can run in 2 different modes known as `WebApplication` or `StandaloneApplication`:
14+
15+
### Web Application
16+
This mode supports most of features like IoC and Dependency Injection, it uses `Controllers` as entry point for the `ApplicationServerAdapter` which could be implemented as any popular Javascript Web Library like [Express](https://expressjs.com/it/) in fact the default adapter is an implementation called `ExpressApplicationServerAdapter` which used Express as web server.
17+
For example given an `ExampleController` defined as:
18+
```typescript
19+
import {Controller, Get} from "properjs/src";
20+
21+
@Controller()
22+
export default class ExampleController {
23+
24+
@Get()
25+
public helloWorld(): String {
26+
return "Hello World"
27+
}
28+
}
29+
```
30+
31+
it will be registered in the `ApplicationContext` and binded to the `ApplicationServerAdapter` to handle inbound requests
32+
33+
```typescript
34+
import {ApplicationFactory} from "properjs/src/core";
35+
36+
async function bootstrap() {
37+
const applicationServerAdapter = await ApplicationFactory.create();
38+
39+
applicationServerAdapter.listen(3000);
40+
}
41+
42+
bootstrap();
43+
```
44+
in this case the `ApplicationFactory` will create an instance of the default server adapter that contains the `ApplicationContext` logic
45+
46+
### Standalone Application
47+
ProperJS can also run in standalone mode, it supports most of the framework features like a Dependency Injection Container, in this case there isn't any server but just an `ApplicationContext` that contains all the `Component` instances.\
48+
For example given an `ExampleComponent` defined as:
49+
```typescript
50+
import {Component} from "properjs/src";
51+
52+
@Component()
53+
export default class ExampleComponent {
54+
55+
public helloWorld(): String {
56+
return "Hello World!"
57+
}
58+
}
59+
60+
```
61+
62+
we can create a standalone application and retrieve the component instance using the `ApplicationContextFactory`
63+
64+
```typescript
65+
import ApplicationContextFactory from "properjs/src/core/application-context-factory";
66+
import ExampleComponent from "./src/example.component";
67+
68+
async function bootstrap() {
69+
const applicationContext = await ApplicationContextFactory.createApplicationContext();
70+
71+
const exampleComponent = applicationContext.get<ExampleComponent>(ExampleComponent)
72+
73+
console.log(exampleComponent.helloWorld())
74+
}
75+
76+
bootstrap();
77+
```
78+
79+
## Features
80+
WIP

0 commit comments

Comments
 (0)