Skip to content

Commit 61f8cd0

Browse files
authored
Merge pull request brookshi#1 from remojansen/master
Added InverisfyJS
2 parents a5b3638 + ae2476e commit 61f8cd0

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

README.md

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ William Stryker: Oh, they serve their purpose... as long as they can be controll
409409

410410
[https://github.com/typeorm/typeorm](https://github.com/typeorm/typeorm)
411411

412-
TypeORM is an Object Relational Mapper (ORM) for node.js written in TypeScript that can be used with TypeScript or JavaScript (ES5, ES6, ES7). Its goal to always support latest JavaScript features and provide features that help you to develop any kind of applications that use database - from small applications with a few tables to large scale enterprise applications.
412+
TypeORM is an Object Relational Mapper (ORM) for node.js written in TypeScript that can be used with TypeScript or JavaScript (ES5, ES6, ES7). Its goal to always support latest JavaScript features and provide features that help you to develop any kind of applications that use database - from small applications with a few tables to large scale enterprise applications.
413413

414414
```ts
415415
import {Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn} from "typeorm";
@@ -464,4 +464,61 @@ Apollo Client can be used in any JavaScript frontend where you want to use data
464464
With PostGraphQL, you can access the power of PostgreSQL through a well designed GraphQL server. PostGraphQL uses PostgreSQL reflection APIs to automatically detect primary keys, relationships, types, comments, and more providing a GraphQL server that is highly intelligent about your data.
465465

466466

467-
### <font color='00A2E8'>**>>>[Inversif
467+
### <font color='00A2E8'>**>>>[InversifyJS](https://github.com/inversify/InversifyJS) - An isomorphic dependency injection library.**</font>
468+
469+
InversifyJS is an inversion of control library that works in both front-end and
470+
back-end applications. InversifyJS is framework agnostic and can be integrated with
471+
many existing frameworks like React applications powered by MobX or Node.js
472+
applications powered by express.
473+
474+
InversifyJS is particularly well integrated with Express thanks to the
475+
[inversify-express-utils](https://github.com/inversify/inversify-express-utils) project:
476+
477+
```ts
478+
import * as express from "express";
479+
import { Response, RequestParams, Controller, Get, Post, Put } from "inversify-express-utils";
480+
import { injectable, inject } from "inversify";
481+
import { interfaces } from "./interfaces";
482+
import { Type } from "./types";
483+
484+
@injectable()
485+
@Controller("/api/user")
486+
class UserController {
487+
488+
@inject(Type.UserRepository) private readonly _userRepository: interfaces.UserRepository,
489+
@inject(Type.Logger) private readonly _logger: interfaces.Logger
490+
491+
@Get("/")
492+
public async get(
493+
@Request() req: express.Request,
494+
@Response() res: express.Response
495+
) {
496+
try {
497+
this._logger.info(`HTTP ${req.method} ${req.url}`);
498+
return await this._userRepository.readAll();
499+
} catch (e) {
500+
this._logger.error(`HTTP ERROR ${req.method} ${req.url}`, e);
501+
res.status(500).json([]);
502+
}
503+
}
504+
505+
@Get("/:email")
506+
public async getByEmail(
507+
@RequestParams("email") email: string,
508+
@Request() req: express.Request,
509+
@Response() res: express.Response
510+
) {
511+
try {
512+
this._logger.info(`HTTP ${req.method} ${req.url}`);
513+
return await this._userRepository.readAll({ where: { email: email } });
514+
} catch (e) {
515+
this._logger.error(`HTTP ERROR ${req.method} ${req.url}`, e);
516+
res.status(500).json([]);
517+
}
518+
}
519+
520+
}
521+
```
522+
523+
The [Inversify GitHub organization](https://github.com/inversify)
524+
also provides the community with some helpers and examples to facilitate the integration of InversifyJS with other popular projects.

0 commit comments

Comments
 (0)