Skip to content

Commit d28c05f

Browse files
first commit
0 parents  commit d28c05f

11 files changed

+840
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
npm-debug.log
4+
5+
#properties
6+
7+
.idea

README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
# typescript-mean-models
3+
4+
The models of the Typescript MEAN(MongoDB-Express-Angular-Node) Stack Boilerplate.
5+
6+
## Models
7+
8+
Since both the backend and the frontend are using the same data-structure, the data-models are stored and maintained independently.
9+
10+
In order to write new models, add a new `my-model.model.ts` file and export it in `index.d.ts`. Once you're done, you can `npm version patch` (or `yarn version`) and then `npm publish` (or `yarn publish`). Like this, the models are retrievable by `npm` (or, `yarn`) in the `backend-` and `frontend-`projects, in order for them to be truly separated into their own git repos.
11+
12+
13+
Step 1. Updates the package version.
14+
<https://yarnpkg.com/en/docs/cli/version>
15+
```bash
16+
// question New Version:
17+
$ yarn version
18+
```
19+
> ```js
20+
> info Current version: 0.0.1
21+
> question New version: 0.1.0
22+
> info New version: 0.1.0
23+
> Done in 9.42s.
24+
> ```
25+
26+
Step 2-A. Publishes a package to the `npm` registry.
27+
<https://yarnpkg.com/en/docs/cli/publish>
28+
```bash
29+
$ yarn publish
30+
```
31+
> Publishes the package defined by the `package.json` in the current directory.
32+
33+
34+
Step 2-B. Publishes a package to the `github` repository.
35+
36+
(1). [Create a new repository](https://help.github.com/articles/creating-a-new-repository/) on GitHub.
37+
38+
To avoid errors, do not initialize the new repository with `README`, `license`, or `gitignore` files.
39+
```
40+
Repository name: typescript-mean-models
41+
```
42+
43+
(2). Open Terminal and change the current working directory to your local project.
44+
Then process git commands:
45+
46+
> Show the working tree status:
47+
48+
```bash
49+
$ git status
50+
```
51+
52+
> If you haven’t initialised a Git repository in the project directory,
53+
> use the below command to initialise the local directory as Git repository:
54+
55+
```bash
56+
$ git init
57+
```
58+
59+
> Push the local repository to `Github` site:
60+
61+
```bash
62+
$ git add .
63+
$ git commit -m "first commit"
64+
$ git remote add origin https://github.com/CodebitsDesign/typescript-mean-models.git
65+
$ git push -u origin master
66+
```
67+
> > and you can simply use the command `git push` next time.
68+

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "typescript-mean-models",
3+
"version": "0.0.1",
4+
"description": "The models of the Typescript MEAN Stack Boilerplate",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "Seokjin Seo <[email protected]>",
10+
"license": "MIT",
11+
"dependencies": {
12+
"bcrypt": "^1.0.2",
13+
"inversify": "^3.3.0",
14+
"reflect-metadata": "^0.1.10"
15+
}
16+
}

src/api.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {User} from "./user.model";
2+
import {Item} from "./item.model";
3+
4+
export interface api {
5+
v1: {
6+
user: StandardRestInterface<User, {}>,
7+
item: StandardRestInterface<Item, {}>
8+
}
9+
}
10+
11+
interface StandardRestInterface<T, K> {
12+
get: {
13+
id: string;
14+
queryParams?: K;
15+
},
16+
post: {
17+
payload: T;
18+
},
19+
put: {
20+
paylaod: T;
21+
},
22+
delete: {
23+
id: string
24+
}
25+
}

src/app-properties.model.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export interface AppProperties {
2+
db: {
3+
host: string;
4+
dbname: string;
5+
port: number;
6+
dbuser: string;
7+
dbpassword: string;
8+
},
9+
redis: {
10+
url: string;
11+
secret: string;
12+
}
13+
}

src/index.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './app-properties.model';
2+
export * from './key.model';
3+
export * from './user.model';

src/item.model.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface Item {
2+
id: string;
3+
title: string;
4+
}

src/key.model.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export interface ResourceKey {
2+
user: string;
3+
id: string;
4+
role: string;
5+
}
6+
7+
export enum Roles {
8+
ITEM_OWNER
9+
}
10+
11+
export enum Activity {
12+
READ_ITEM, UPDATE_ITEM
13+
}

src/user.model.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export interface User {
2+
id: string;
3+
email: string;
4+
password: {
5+
hash: string;
6+
algo: HashingAlgo;
7+
}
8+
}
9+
10+
type HashingAlgo = 'bcrypt'

tsconfig.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es6",
4+
"lib": ["es6"],
5+
"types": ["reflect-metadata"],
6+
"module": "commonjs",
7+
"outDir": "dist",
8+
"experimentalDecorators": true,
9+
"emitDecoratorMetadata": true
10+
},
11+
"include": [
12+
"src/**/*.ts"
13+
],
14+
"exclude": [
15+
"node_modules"
16+
]
17+
}

0 commit comments

Comments
 (0)