-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# compiled output | ||
/bundle | ||
/dist | ||
/tmp | ||
/tmp-* | ||
/out-tsc | ||
bundle.umd.js | ||
|
||
|
||
|
||
|
||
# dependencies | ||
/node_modules | ||
|
||
|
||
# misc | ||
/.sass-cache | ||
/connect.lock | ||
/coverage | ||
/libpeerconnection.log | ||
npm-debug.log | ||
testem.log | ||
/typings | ||
|
||
# e2e | ||
/e2e/*.js | ||
/e2e/*.map | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.vscode | ||
dist/ | ||
src/ | ||
/scripts | ||
/docs | ||
/preview | ||
/tests | ||
|
||
tsconfig.json | ||
npm-debug.log* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/.svn": true, | ||
"**/.hg": true, | ||
"**/CVS": true, | ||
"**/.DS_Store": true, | ||
// "index.*": true, | ||
// "client.*": true, | ||
// "dist": true, | ||
// "bundle": true, | ||
"node_modules": true | ||
}, | ||
"workbench.colorCustomizations": { | ||
"activityBar.background": "#8b31d4" | ||
}, | ||
"editor.rulers": [ | ||
100, | ||
120 | ||
], | ||
"html.format.wrapAttributes": "force-aligned", | ||
"workbench.colorTheme": "Default Light+" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "0.1.0", | ||
"command": "tnp", | ||
"isShellCommand": true, | ||
"args": [ | ||
"build:dist:watch" | ||
], | ||
"showOutput": "always" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# isomorphic-rest | ||
Server/Client (nodejs/browser) framework based on isomorphic solution for ExpressJS and Angular 5 | ||
|
||
|
||
WORK IN PROGRESS | ||
|
||
### | ||
Example app here: https://github.com/darekf77/example-isomorphic-rest | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './index'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './index'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "morphi", | ||
"version": "0.0.0", | ||
"description": "Isomorphic solution for expressjs and angular5", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "./node_modules/.bin/ts-node ./node_modules/typescript-npm-project/index.ts", | ||
"build:publish": "./node_modules/.bin/ts-node ./node_modules/typescript-npm-project/index.ts --publish", | ||
"build:clean": "./node_modules/.bin/ts-node ./node_modules/typescript-npm-project/index.ts --clean" | ||
}, | ||
"tnp": { | ||
"type": "isomorphic-lib", | ||
"resources": [ | ||
"README.md" | ||
] | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/darekf77/morphi.git" | ||
}, | ||
"author": "Dariusz Filipiak", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/darekf77/morphi/issues" | ||
}, | ||
"homepage": "https://github.com/darekf77/morphi#readme", | ||
"dependencies": { | ||
"@types/express": "^4.11.0", | ||
"@types/lodash": "^4.14.85", | ||
"@types/socket.io": "^1.4.31", | ||
"accepts": "^1.3.4", | ||
"body-parser": "^1.18.2", | ||
"circular-json": "^0.5.1", | ||
"cookie-parser": "^1.4.3", | ||
"cors": "^2.8.4", | ||
"errorhandler": "^1.5.0", | ||
"express": "^4.16.2", | ||
"json5": "^0.5.1", | ||
"lodash": "^4.17.4", | ||
"method-override": "^2.3.10", | ||
"ng2-rest": "^9.0.10", | ||
"reflect-metadata": "^0.1.10", | ||
"rxjs": "^5.5.2", | ||
"socket.io": "^2.0.4", | ||
"tslib": "^1.8.1", | ||
"typeorm": "^0.1.9" | ||
}, | ||
"devDependencies": { | ||
"@ngtools/webpack": "^1.9.3", | ||
"isomorphic-region-loader": "0.0.1", | ||
"typescript": "^2.6.2", | ||
"webpack": "^3.10.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { | ||
__ENDPOINT, isNode, | ||
GET, PUT, POST, DELETE, | ||
Response, | ||
PathParam, BodyParam, OrmConnection | ||
} from "./index"; | ||
|
||
import { Repository, Connection } from "typeorm"; | ||
import { Observable } from "rxjs/Observable"; | ||
|
||
const model = 'aaaaaa' | ||
|
||
@__ENDPOINT(undefined, BaseCRUD) | ||
export abstract class BaseCRUD<T> { | ||
|
||
@OrmConnection connection: Connection; | ||
public get repository(): Repository<T> { | ||
return this.repo; | ||
} | ||
private repo: Repository<any>; | ||
public abstract entity: T; | ||
|
||
|
||
public __model = { | ||
getAll: () => this.getAll(), | ||
getOneBy: (id: number) => this.getBy(id), | ||
deleteBy: (id: number) => this.getBy(id), | ||
updateById: (id: number, item: T) => this.updateById(id, item), | ||
create: (item: T) => this.create(item) | ||
} | ||
|
||
constructor() { | ||
console.log('Perfect') | ||
//#region backend | ||
if (isNode && this.entity) { | ||
this.repo = this.connection.getRepository(this.entity as any) | ||
} | ||
//#endregion | ||
} | ||
|
||
@GET(`/${model}`) | ||
getAll(): Response<T[]> { | ||
//#region backend | ||
return async () => { | ||
const models = await this.repo.find(); | ||
return models; | ||
} | ||
//#endregion | ||
} | ||
|
||
@GET(`/${model}/:id`) | ||
getBy( @PathParam(`id`) id: number): Response<T> { | ||
//#region backend | ||
return async () => { | ||
const model = await this.repo.findOneById(id) | ||
return model; | ||
} | ||
//#endregion | ||
} | ||
|
||
@PUT(`/${model}/:id`) | ||
updateById( @PathParam(`id`) id: number, @BodyParam() item: T): Response<T> { | ||
//#region backend | ||
return async () => { | ||
await this.repo.updateById(id, item); | ||
return await this.repo.findOneById(id) | ||
} | ||
//#endregion | ||
} | ||
|
||
@POST(`/${model}`) | ||
create( @BodyParam() item: T): Response<T> { | ||
//#region backend | ||
return async () => { | ||
const model = await this.repo.create(item) | ||
return model; | ||
} | ||
//#endregion | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* File empty for purpose */ export * from './index'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* File empty for purpose */ export * from './index'; |