Skip to content

Commit

Permalink
refactor: migrate to es6
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Nov 12, 2021
1 parent 99ac763 commit 536ba0a
Show file tree
Hide file tree
Showing 30 changed files with 21,876 additions and 2,892 deletions.
12 changes: 12 additions & 0 deletions .babelrc
@@ -0,0 +1,12 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
14 changes: 14 additions & 0 deletions .editorconfig
@@ -0,0 +1,14 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js}]
charset = utf-8
1 change: 1 addition & 0 deletions .eslintignore
@@ -0,0 +1 @@
src/predefine.apidoc.js
11 changes: 11 additions & 0 deletions .eslintrc
@@ -0,0 +1,11 @@
{
"extends": [
"airbnb-base",
"plugin:prettier/recommended",
"plugin:jsdoc/recommended"
],
"plugins": ["prettier", "jsdoc"],
"rules": {
"prettier/prettier": "error"
}
}
30 changes: 11 additions & 19 deletions .gitignore
Expand Up @@ -2,29 +2,21 @@
logs
*.log

#Temporary data
.tmp

# Runtime data
# Runtime
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
# Temporary
.tmp
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
# Dependencies
node_modules
doc
startup.sh

# Coverage
libcov
coverage
.nyc_output

# Docs
7 changes: 0 additions & 7 deletions .jsbeautifyrc

This file was deleted.

21 changes: 0 additions & 21 deletions .jshintrc

This file was deleted.

29 changes: 12 additions & 17 deletions .npmignore
@@ -1,21 +1,16 @@
logs
*.log
pids
*.pid
*.seed
.tmp
.grunt
node_modules
ssl
.DS_STORE
*~
.idea
nbproject
libcov
coverage
.nyc_output
test
.git
.gitignore
.tmp
*.swo
*.swp
*.swn
*.swm
*.log
.jshintrc
.editorconfig
examples
docs
doc.html
.travis.yml
Gruntfile.js
Gruntfile.js
2 changes: 1 addition & 1 deletion .npmrc
@@ -1,2 +1,2 @@
registry = https://registry.npmjs.com/
registry = "https://registry.npmjs.com/"
git-tag-version = false
Empty file added .prettierignore
Empty file.
6 changes: 6 additions & 0 deletions .prettierrc
@@ -0,0 +1,6 @@
{
"printWidth": 80,
"singleQuote": true,
"semi": true,
"trailingComma": "es5"
}
12 changes: 8 additions & 4 deletions .travis.yml
@@ -1,6 +1,10 @@
language: node_js
services: mongodb
services:
- mongodb
node_js:
- '11.12.0'
before_script:
- npm install -g grunt-cli
- node
script:
- commitlint-travis
- npm test
after_success: npm run coverage

52 changes: 0 additions & 52 deletions Gruntfile.js

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE
@@ -1,9 +1,9 @@
The MIT License (MIT)

Copyright (c) 2019 lykmapipo & Contributors
Copyright (c) lykmapipo & Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 changes: 19 additions & 9 deletions README.md
@@ -1,24 +1,34 @@
# mongoose-exportable

[![Build Status](https://travis-ci.org/lykmapipo/mongoose-exportable.svg?branch=master)](https://travis-ci.org/lykmapipo/mongoose-exportable)
[![Dependencies Status](https://david-dm.org/lykmapipo/mongoose-exportable/status.svg)](https://david-dm.org/lykmapipo/mongoose-exportable)
[![Build Status](https://app.travis-ci.com/lykmapipo/mongoose-exportable.svg?branch=master)](https://app.travis-ci.com/lykmapipo/mongoose-exportable)
[![Dependencies Status](https://david-dm.org/lykmapipo/mongoose-exportable.svg)](https://david-dm.org/lykmapipo/mongoose-exportable)
[![Coverage Status](https://coveralls.io/repos/github/lykmapipo/mongoose-exportable/badge.svg?branch=master)](https://coveralls.io/github/lykmapipo/mongoose-exportable?branch=master)
[![GitHub License](https://img.shields.io/github/license/lykmapipo/mongoose-exportable)](https://github.com/lykmapipo/mongoose-exportable/blob/develop/LICENSE)

mongoose plugin to add exports behavior.
[![Commitizen Friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Code Style](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)
[![npm version](https://img.shields.io/npm/v/@lykmapipo/mongoose-exportable)](https://www.npmjs.com/package/@lykmapipo/mongoose-exportable)

mongoose plugin to add aggregations behaviour.

## Requirements

- NodeJS v9.3+
- [NodeJS v13+](https://nodejs.org)
- [Npm v6.12+](https://www.npmjs.com/)
- [MongoDB v4+](https://www.mongodb.com/)
- [Mongoose v6+](https://github.com/Automattic/mongoose)

## Install
```sh
$ npm install --save @lykmapipo/mongoose-exportable
$ npm install --save mongoose @lykmapipo/mongoose-exportable
```

## Usage

```javascript
const mongoose = require('mongoose');
const exportable = require('@lykmapipo/mongoose-exportable');
import mongoose from 'mongoose';
import exportable from '@lykmapipo/mongoose-exportable';

const UserSchema = new Schema({ name: { type: String, exportable: true } });
UserSchema.plugin(exportable);
Expand Down Expand Up @@ -90,10 +100,10 @@ It will be nice, if you open an issue first so that we can know what is going on
## Licence
The MIT License (MIT)

Copyright (c) 2019 lykmapipo & Contributors
Copyright (c) lykmapipo & Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions SECURITY.md
@@ -0,0 +1,3 @@
# Security

If you find a security vulnerability in mongoose-exportable, file a [new issue](https://github.com/lykmapipo/mongoose-exportable/issues).
Empty file added examples/.env
Empty file.
7 changes: 7 additions & 0 deletions examples/.eslintrc
@@ -0,0 +1,7 @@
{
"extends": ["airbnb-base", "plugin:prettier/recommended"],
"plugins": ["prettier"],
"rules": {
"no-console": "off"
}
}
Empty file added examples/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions examples/index.js
@@ -0,0 +1,13 @@
import fs from 'fs';
import { connect, model, Schema } from '@lykmapipo/mongoose-common';
import exportable from '../src';

const UserSchema = new Schema({ name: { type: String, exportable: true } });
UserSchema.plugin(exportable);
const User = model('User', UserSchema);

// fs use
connect(() => {
const out = fs.createWriteStream('out.csv');
User.exportCsv().pipe(out);
});

0 comments on commit 536ba0a

Please sign in to comment.