Skip to content

Commit 3bab440

Browse files
author
Checkiteasy
committed
Init
0 parents  commit 3bab440

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5759
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
lib/

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
docs/
2+
src/
3+
.prettierrc
4+
.gitignore
5+
tsconfig.json
6+
typedoc.js
7+
yarn.lock

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"tabWidth": 4,
4+
"semi": true,
5+
"trailingComma": "none"
6+
}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.1.0] - 2019-04-07
11+
12+
[unreleased]: https://github.com/Pop-Code/nestjs-mongo/compare/v0.1.0...HEAD

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Pop-Code
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# nestjs-mongo
2+
3+
[NestJS Mongo][doc-link] is a module that provide a little orm. Build with typescript and the nodejs mogodb driver
4+
5+
### [Install FROM NPM][npm]
6+
7+
```bash
8+
npm install nestjs-mongo
9+
# or unig yarn
10+
yarn install nestjs-mongo
11+
```
12+
13+
### Usage
14+
15+
An example of nestjs module that import the nestjs-mongo
16+
17+
```ts
18+
// module.ts
19+
import { Module } from '@nestjs/common';
20+
import { MongoModule } from 'nestjs-mongo';
21+
22+
@Module({
23+
imports: [
24+
MongoModule.forRootAsync({
25+
imports: [],
26+
useFactory: (config: ConfigService) => ({
27+
uri: config.mongoUri
28+
}),
29+
inject: [MyConfigService]
30+
})
31+
]
32+
})
33+
export class MyModule {}
34+
```
35+
36+
TODO, write doc.
37+
38+
### Documentation
39+
40+
A typedoc is generated and available on github [https://pop-code.github.io/nestjs-mongo][doc-link]
41+
42+
### [CHANGELOG][changelog]
43+
44+
#### TODO
45+
46+
- [ ] write docs
47+
- [ ] add more tests
48+
- [ ] add examples
49+
50+
[npm]: https://www.npmjs.com/package/nestjs-mongo
51+
[doc-link]: https://pop-code.github.io/nestjs-mongo
52+
[changelog]: https://github.com/Pop-Code/nestjs-mongo/blob/master/CHANGELOG.md

jest.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// jest.config.js
2+
module.exports = {
3+
moduleFileExtensions: ['js', 'json', 'ts'],
4+
rootDir: 'src',
5+
testRegex: '.spec.ts$',
6+
transform: {
7+
'^.+\\.(t|j)s$': 'ts-jest'
8+
},
9+
coverageDirectory: '../coverage',
10+
testEnvironment: 'node',
11+
verbose: true
12+
};

package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "nestjs-mongo",
3+
"version": "0.1.0",
4+
"description": "A NestJS module that provide a simple mongodb orm like",
5+
"keywords": [
6+
"nestjs",
7+
"module",
8+
"database",
9+
"mongodb",
10+
"mongo"
11+
],
12+
"main": "./lib/index.js",
13+
"types": "./lib/index.d.ts",
14+
"repository": "git@github.com:Pop-Code/nestjs-mongo.git",
15+
"author": "Rmannn <alex.hermann@pop-code.com>",
16+
"license": "MIT",
17+
"peerDependencies": {
18+
"@nestjs/common": "^5.4.0 || ^6",
19+
"@nestjs/core": "^5.4.0 || ^6",
20+
"typescript": "^3.0.0"
21+
},
22+
"dependencies": {
23+
"@nestjs/swagger": "^3.0.2",
24+
"class-transformer": "^0.2.0",
25+
"class-validator": "^0.9.1",
26+
"mongodb": "^3.2.3"
27+
},
28+
"devDependencies": {
29+
"@nestjs/common": "^6.0.5",
30+
"@nestjs/core": "^6.0.5",
31+
"@nestjs/testing": "^6.0.5",
32+
"@types/jest": "^24.0.11",
33+
"@types/mongodb": "^3.1.17",
34+
"jest": "^24.7.1",
35+
"reflect-metadata": "^0.1.13",
36+
"rxjs": "^6.4.0",
37+
"ts-jest": "^24.0.2",
38+
"ts-node": "^8.0.3",
39+
"tsconfig-paths": "^3.8.0",
40+
"typedoc": "^0.14.2",
41+
"typescript": "^3.4.2"
42+
},
43+
"scripts": {
44+
"build": "rm -Rf ./lib && tsc",
45+
"doc": "rm -Rf ./docs && typedoc ./src && touch ./docs/.nojekyll",
46+
"test": "jest",
47+
"test:watch": "jest --watch",
48+
"test:cov": "jest --coverage",
49+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand"
50+
}
51+
}

src/classes/history.action.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @module nestjs-mongo
3+
*/
4+
5+
import { ApiModelProperty } from '@nestjs/swagger';
6+
import { IsString, IsDate } from 'class-validator';
7+
8+
export class HistoryAction {
9+
@ApiModelProperty({
10+
description: 'A message describing the action'
11+
})
12+
@IsString()
13+
action: string;
14+
15+
@ApiModelProperty({
16+
description: 'The date of the action',
17+
type: 'string',
18+
format: 'date-time'
19+
})
20+
@IsDate()
21+
date: Date;
22+
23+
constructor(action: string, date: Date) {
24+
this.action = action;
25+
this.date = date;
26+
}
27+
}

src/classes/history.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @module nestjs-mongo
3+
*/
4+
5+
import { HistoryAction } from './history.action';
6+
import { IsArray } from 'class-validator';
7+
import { ApiModelProperty } from '@nestjs/swagger';
8+
import { Type } from 'class-transformer';
9+
10+
export class HistoryActions {
11+
@ApiModelProperty({
12+
description: 'A list of HisotryAction',
13+
isArray: true,
14+
type: HistoryAction
15+
})
16+
@IsArray()
17+
@Type(() => HistoryAction)
18+
protected actions: HistoryAction[] = [];
19+
20+
get length() {
21+
return this.actions.length;
22+
}
23+
24+
add(historyAction: HistoryAction) {
25+
this.actions.push(historyAction);
26+
}
27+
28+
clear(historyAction: HistoryAction) {
29+
this.actions = [];
30+
}
31+
32+
getActions() {
33+
return this.actions;
34+
}
35+
}

0 commit comments

Comments
 (0)