Skip to content

Commit

Permalink
Merge pull request #17 from pdupavillon/typescript
Browse files Browse the repository at this point in the history
migration to typescript
  • Loading branch information
pdupavillon authored Apr 5, 2018
2 parents cda5e94 + 24d0576 commit e581ffd
Show file tree
Hide file tree
Showing 24 changed files with 617 additions and 260 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.git
npm-debug.log
dist
13 changes: 9 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package.json
test.js
mocha.opts
.travis.yml
.gitignore
.npmignore
.travis.yml
base.tsconfig.json
mocha.opts
package-lock.json
package.json
src/
test/
example/
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ language: node_js
node_js:
- '6'
dist: trusty
script:
- npm run build:prod
deploy:
provider: npm
email: [email protected]
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ npm install express-recaptcha --save
## Usage
### Init
```javascript
//### New usage (express-recaptcha version >= 3.*.*)
//### New usage (express-recaptcha version >= 4.*.*)
var Recaptcha = require('express-recaptcha');
var Recaptcha = require('express-recaptcha').Recaptcha;
//import Recaptcha from 'express-recaptcha'
var recaptcha = new Recaptcha('SITE_KEY', 'SECRET_KEY');
//or with options
var recaptcha = new Recaptcha('SITE_KEY', 'SECRET_KEY', options);
```

```javascript
//--- Old usage (express-recaptcha version <= 2.3.0)
var recaptcha = require('express-recaptcha');
//...
recaptcha.init('SITE_KEY', 'SECRET_KEY');
//or
recaptcha.init('SITE_KEY', 'SECRET_KEY', options);
//--- Old usage (express-recaptcha version 3.*.*)
var Recaptcha = require('express-recaptcha');
//import Recaptcha from 'express-recaptcha'
var recaptcha = new Recaptcha('SITE_KEY', 'SECRET_KEY');
//or with options
var recaptcha = new Recaptcha('SITE_KEY', 'SECRET_KEY', options);
```
`options` available properties
* `onload` The callback function that gets called when all the dependencies have loaded.
Expand Down Expand Up @@ -90,7 +90,7 @@ var express = require('express');
var bodyParser = require('body-parser');
var pub = __dirname + '/public';
var app = express();
var Recaptcha = require('express-recaptcha');
var Recaptcha = require('express-recaptcha').Recaptcha;

var recaptcha = new Recaptcha('SITE_KEY', 'SECRET_KEY');

Expand Down Expand Up @@ -131,7 +131,7 @@ var express = require('express');
var bodyParser = require('body-parser');
var pub = __dirname + '/public';
var app = express();
var Recaptcha = require('express-recaptcha');
var Recaptcha = require('express-recaptcha').Recaptcha;

var recaptcha = new Recaptcha('SITE_KEY', 'SECRET_KEY');

Expand Down
22 changes: 22 additions & 0 deletions base.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"declaration": true,
"noImplicitAny": true,
"strict": true,
"removeComments": true,
"skipLibCheck": false,
"sourceMap": false,
"listFiles": false,
"newLine": "LF",
"noEmitOnError": true,
"allowJs": false
},
"exclude": [
"node_modules",
"dist"
]
}
6 changes: 3 additions & 3 deletions example/server.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const express = require('express')
const bodyParser = require('body-parser')
const Recaptcha = require('../lib/express-recaptcha')
const RECAPTCHA_SITE_KEY = 'xxxxxx'
const RECAPTCHA_SECRET_KEY = 'xxxxxx'
const Recaptcha = require('../dist').Recaptcha
const RECAPTCHA_SITE_KEY = 'xxxx'
const RECAPTCHA_SECRET_KEY = 'xxxx'
const app = express()
const recaptcha = new Recaptcha(RECAPTCHA_SITE_KEY, RECAPTCHA_SECRET_KEY)

Expand Down
1 change: 1 addition & 0 deletions mocha.opts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
-R spec
--recursive
--check-leaks
--watch-extensions ts
Loading

0 comments on commit e581ffd

Please sign in to comment.