Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
darekf77 committed Feb 15, 2018
0 parents commit 3d4d16b
Show file tree
Hide file tree
Showing 29 changed files with 1,175 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .gitignore
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
10 changes: 10 additions & 0 deletions .npmignore
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*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock = false
23 changes: 23 additions & 0 deletions .vscode/settings.json
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+"
}
11 changes: 11 additions & 0 deletions .vscode/tasks.json
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"
}
9 changes: 9 additions & 0 deletions README.md
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

1 change: 1 addition & 0 deletions browser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './index';
7 changes: 7 additions & 0 deletions browser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions browser.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './index';
7 changes: 7 additions & 0 deletions client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src';
7 changes: 7 additions & 0 deletions index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions package.json
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"
}
}
81 changes: 81 additions & 0 deletions src/base-crud-model.ts
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
}

}
1 change: 1 addition & 0 deletions src/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* File empty for purpose */ export * from './index';
1 change: 1 addition & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* File empty for purpose */ export * from './index';
Loading

0 comments on commit 3d4d16b

Please sign in to comment.