Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Aug 9, 2017
2 parents da77526 + b360b27 commit b86ee1e
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 5 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,11 @@
<a name="1.0.0"></a>
# 1.0.0 (2017-08-09)


### Features

* initial commit ([da77526](https://github.com/adonisjs/adonis-cors/commit/da77526))
* **instructions:** add instructions files ([d800360](https://github.com/adonisjs/adonis-cors/commit/d800360))



77 changes: 77 additions & 0 deletions README.md
@@ -0,0 +1,77 @@
# Adonis Cors :triangular_ruler:

Adonis Cors is a middleware to allow CORS requests inside your application. It is a thin middleware with zero dependencies.

[![NPM Version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Appveyor][appveyor-image]][appveyor-url]
[![Coveralls][coveralls-image]][coveralls-url]

<img src="http://res.cloudinary.com/adonisjs/image/upload/q_100/v1497112678/adonis-purple_pzkmzt.svg" width="200px" align="right" hspace="30px" vspace="100px">

## Node/OS Target

This repo/branch is supposed to run fine on all major OS platforms and targets `Node.js >=7.0`

## Development

Great! If you are planning to contribute to the framework, make sure to adhere to following conventions, since a consistent code-base is always joy to work with.

Run the following command to see list of available npm scripts.

```
npm run
```

### Tests & Linting

1. Lint your code using standardJs. Run `npm run lint` command to check if there are any linting errors.
2. Make sure you write tests for all the changes/bug fixes.
3. Also you can write **regression tests**, which shows that something is failing but doesn't breaks the build. Which is actually a nice way to show that something fails. Regression tests are written using `test.failing()` method.
4. Make sure all the tests are passing on `travis` and `appveyor`.

### General Practices

Since Es6 is in, you should strive to use latest features. For example:

1. Use `Spread` over `arguments` keyword.
2. Never use `bind` or `call`. After calling these methods, we cannot guarantee the scope of any methods and in AdonisJs codebase we do not override the methods scope.
3. Make sure to write proper docblock.

## Issues & PR

It is always helpful if we try to follow certain practices when creating issues or PR's, since it will save everyone's time.

1. Always try creating regression tests when you find a bug (if possible).
2. Share some context on what you are trying to do, with enough code to reproduce the issue.
3. For general questions, please create a forum thread.
4. When creating a PR for a feature, make sure to create a parallel PR for docs too.


## Regression Tests

Regression tests are tests, which shows how a piece of code fails under certain circumstance, but the beauty is even after the failure, the test suite will never fail. Actually is a nice way to notify about bugs, but making sure everything is green.

The regression tests are created using

```
test.failing('2 + 2 is always 4, but add method returns 6', (assert) => {
assert.true(add(2, 2), 4)
})
```

Now since the `add` method has a bug, it will return `6` instead of `4`. But the build will pass.

[appveyor-image]: https://img.shields.io/appveyor/ci/thetutlage/adonis-cors/master.svg?style=flat-square

[appveyor-url]: https://ci.appveyor.com/project/thetutlage/adonis-cors

[npm-image]: https://img.shields.io/npm/v/@adonisjs/cors.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@adonisjs/cors

[travis-image]: https://img.shields.io/travis/adonisjs/adonis-cors/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/adonisjs/adonis-cors

[coveralls-image]: https://img.shields.io/coveralls/adonisjs/adonis-cors/master.svg?style=flat-square

[coveralls-url]: https://coveralls.io/github/adonisjs/adonis-cors
24 changes: 24 additions & 0 deletions instructions.js
@@ -0,0 +1,24 @@
'use strict'

/*
* adonis-auth
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

const path = require('path')

module.exports = async function (cli) {
try {
await cli.copy(
path.join(__dirname, './example/cors.js'),
path.join(cli.helpers.configPath(), 'cors.js')
)
cli.command.completed('create', 'config/cors.js')
} catch (error) {
// ignore error
}
}
26 changes: 26 additions & 0 deletions instructions.md
@@ -0,0 +1,26 @@
## Register provider

Start by registering the provider inside `start/app.js` file.

```js
const providers = [
'@adonisjs/cors/providers/CorsProvider'
]
```


## Register middleware

The next thing is to register the middleware globally. Make sure `Cors` middleware is the first middleware in the stack.

The middleware is registered inside `start/kernel.js` file.

```js
const globalMiddleware = [
'Adonis/Middleware/Cors'
]
```

## Config

The config file has been saved inside `config/cors.js` file. Feel free to tweak it accordingly.
59 changes: 56 additions & 3 deletions package-lock.json

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

26 changes: 24 additions & 2 deletions package.json
Expand Up @@ -20,8 +20,9 @@
"author": "virk",
"license": "MIT",
"devDependencies": {
"@adonisjs/sink": "^1.0.11",
"@adonisjs/sink": "^1.0.12",
"coveralls": "^2.13.1",
"cz-conventional-changelog": "^2.0.0",
"japa": "^1.0.3",
"japa-cli": "^1.0.1",
"nyc": "^11.1.0",
Expand All @@ -33,5 +34,26 @@
"src",
"test"
]
}
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"bin": {
"cors": "index.js"
},
"directories": {
"example": "example",
"test": "test"
},
"dependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/adonisjs/adonis-cors.git"
},
"bugs": {
"url": "https://github.com/adonisjs/adonis-cors/issues"
},
"homepage": "https://github.com/adonisjs/adonis-cors#readme"
}

0 comments on commit b86ee1e

Please sign in to comment.