Gathering detailed insights and metrics for @mvx/typeorm-adapter
Gathering detailed insights and metrics for @mvx/typeorm-adapter
Gathering detailed insights and metrics for @mvx/typeorm-adapter
Gathering detailed insights and metrics for @mvx/typeorm-adapter
Decorator, Ioc, AOP MVC frameworker, base on koa.
npm install @mvx/typeorm-adapter
Typescript
Module System
Node Version
NPM Version
TypeScript (94.61%)
HTML (3.34%)
JavaScript (2.05%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
7 Stars
687 Commits
2 Forks
1 Watchers
4 Branches
1 Contributors
Updated on Dec 08, 2021
Latest Version
4.0.0-beta5
Package Id
@mvx/typeorm-adapter@4.0.0-beta5
Unpacked Size
157.43 kB
Size
16.78 kB
File Count
36
NPM Version
6.13.6
Node Version
13.8.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This repo is for distribution on npm
. The source for this module is in the
main repo.
@mvx/typeorm-adapter
is model parser for MVC frameworker. base on ioc @tsdi
. help you develop your project easily.
You can install this package either with npm
1 2npm install @mvx/typeorm-adapter 3 4
create application
1import { MvcApplication, DefaultMvcMiddlewares, MvcModule, MvcServer } from '@mvx/mvc';
2import { TypeOrmModule } from '@mvx/typeorm-adapter';
3
4// 1. use MvcHostBuilder to boot application.
5MvcApplication.run();
6
7// 2. use bootstrap module to boot application
8
9@MvcModule({
10 // baseURL: __dirname,
11 imports: [
12 TypeOrmModule
13 //... you service, or controller, some extends module.
14 ],
15 debug: true
16})
17class MvcApi {
18 constructor() {
19 console.log('boot application');
20 }
21}
22
23
24// 3. use MvcHostBuilder to boot application module.
25
26@MvcModule({
27 imports: [
28 TypeOrmModule
29 // ... /... you service, or controller, some extends module.
30 // DebugLogAspect
31 ],
32 middlewares: DefaultMvcMiddlewares,
33 // bootstrap: MvcServer
34})
35class MvcApi {
36
37}
38
39MvcApplication.run(MvcApi);
40
41
42//4. use bootstrap module to boot application by main.
43@MvcModule({
44 imports: [
45 TypeOrmModule
46 // ...
47 ],
48 // bootstrap: MvcServer,
49 debug: true
50})
51class MvcApi {
52 constructor() {
53 console.log('boot application');
54 }
55
56 static main() {
57 console.log('run mvc api...');
58 MvcApplication.run(MvcApi);
59 }
60}
61
62
default setting load controllers in your project folder
/controllers
ResultValue
, also you can return base type or object, it deal with JsonResult.async
or sync
. Have provide FileResult
, JsonResult
,
RedirectResult
, ViewResult
.BaseController
, it has implements some mothod to create the ResultValue
types.@Cors
decorator in class or method.define as:
1import { Controller, Get, Post, IContext, ContextToken, RequestMethod, Model, Field, Cors } from '@mvx/mvc'; 2import { Inject } from '@tsdi/core'; 3import { Mywork } from '../bi/Mywork'; 4import { User } from '../models'; 5 6@Cors 7@Controller('/users') 8export class UserController { 9 10 // @Inject(symbols.IContext) 11 // context: IContext; 12 constructor(private work: Mywork) { 13 14 } 15 16 @Get('') 17 index() { 18 console.log('home index invorked', this.work); 19 return this.work.workA(); 20 } 21 22 // @Cors([RequestMethod.Post]) 23 // also can define as below 24 // @Cors(['Post','Get']) 25 // @Cors('POST,GET') 26 @Post('/add') 27 async addUser(user: User, @Inject(ContextToken) ctx: IContext) { 28 console.log('user:', user); 29 console.log('request body', ctx.request.body); 30 return this.work.save(user); 31 } 32 33 @Get('/sub') 34 sub() { 35 return this.work.workB(); 36 } 37 38 @Get('/:name') 39 getPerson(name: string) { 40 return this.work.find(name); 41 } 42 43 @Get('/find/:name') 44 query(name: string, @Inject(ContextToken) ctx) { 45 console.log(ctx); 46 return this.work.find(name); 47 } 48 49 @Get('/test/:id') 50 parmtest(id: number) { 51 if (id === 1) { 52 return this.work.workA(); 53 } else if (id === 2) { 54 return this.work.workB(); 55 } else { 56 return 'notFound'; 57 } 58 } 59 60 @Post('/posttest/:id') 61 postTest(id: number) { 62 return { 63 id: id 64 } 65 } 66 67} 68 69 70@Controller('/') 71export class HomeController extends BaseController { 72 73 // @Inject(ContextToken) 74 // context: IContext; 75 constructor() { 76 super(); 77 } 78 79 @Get('') 80 index(): ResultValue { 81 return this.view('index.html'); 82 } 83 84 @Get('/index2') 85 home2(): ResultValue { 86 return this.view('index2.html'); 87 } 88 89 @Post('/goto/:pageName') 90 gotoPage(pageName: string): ResultValue { 91 return this.redirect( '/' + pageName); 92 } 93} 94 95
Auto load Aspect service from folder /aop
in your project.
see simple demo
1import { Aspect, Around, Joinpoint, Before } from '@tsdi/aop'; 2 3@Aspect 4export class DebugLog { 5 @Around('execution(*Controller.*)') 6 log(joinPoint: Joinpoint) { 7 console.log('aspect append log, method name:', joinPoint.fullName, ' state:', joinPoint.state, ' Args:', joinPoint.args , ' returning:', joinPoint.returning, ' throwing:', joinPoint.throwing); 8 } 9 10 @Before(/Controller.\*$/) 11 Beforlog(joinPoint: Joinpoint) { 12 console.log('aspect Befor log:', joinPoint.fullName); 13 } 14} 15 16
default setting load middlewares in your project folder
/middlewares
1import { Middleware, IMiddleware, Application, Configuration } from '@mvx/mvc'; 2import { IContainer, Injectable } from '@tsdi/core'; 3 4 5@Middleware('logger') 6export class Logger implements IMiddleware { 7 8 constructor() { 9 10 } 11 12 async execute (ctx, next) { 13 let start = Date.now(); 14 await next(); 15 const ms = Date.now() - start; 16 console.log(`mylog: ${ctx.method} ${ctx.url} - ${ms}ms`); 17 let end = new Date(); 18 } 19 20} 21
1.0.1
0.6.3
0.5.5
v0.5.3
v0.5.1
add Log aop aspect service. for Log easy. default user console to log, can config logLib
,logConfig
in your config.js
to use third logger lib. eg. { logLib: 'log4js', logConfig:{...} }
.
has implements log4js adapter see code
DebugAspect, config debug: true
, in your config.js
, will auto log debug info.
AnnotationLogerAspect @annotation(Logger), logger some state via @Logger decorator config.
add Annotation Auth aspect service AuthAspect
to support yourself auth check easy. eg.
1@Aspect 2export class YourSecrityAspect { 3 // before AuthAspect.auth check some. 4 @Before('execution(AuthAspect.auth)', 'authAnnotation') 5 sessionCheck(authAnnotation: AuthorizationMetadata[], joinPoint: Joinpoint) { 6 //TODO: you check by authAnnotation 7 } 8} 9
MIT © Houjun
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More