Skip to content

Commit

Permalink
feat: use typescript, add interfaces for options
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper committed May 11, 2019
1 parent bb19d22 commit ed1a4a4
Show file tree
Hide file tree
Showing 16 changed files with 12,812 additions and 2,549 deletions.
8 changes: 3 additions & 5 deletions .codecov.yml
@@ -1,10 +1,8 @@
coverage:
range: "50..100"
status:
project:
default:
target: auto
threshold: 10
base: auto
project: no
patch: no
comment:
require_changes: yes
behavior: once
11 changes: 5 additions & 6 deletions .editorconfig
@@ -1,14 +1,13 @@
# http://editorconfig.org
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_size = 2

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
trim_trailing_whitespace = false
28 changes: 18 additions & 10 deletions .gitignore
@@ -1,28 +1,36 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

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

# Coverage directory used by tools like istanbul
# Coverage directory
coverage

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

# node-waf configuration
.lock-wscript

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

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
# Dependency directories
node_modules
/.nyc_output
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
.vscode/*
!.vscode/launch.json

# build
build
docs
dist
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

5 changes: 2 additions & 3 deletions LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
MIT License

Copyright (c) 2015 Scott Cooper
Copyright 2019 Scott Cooper <scttcper@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,4 +19,3 @@ 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.

53 changes: 53 additions & 0 deletions circle.yml
@@ -0,0 +1,53 @@
version: 2.1
jobs:
test:
docker:
- image: circleci/node:10
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: npm-install
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: test
command: npm run test:ci
environment:
JEST_JUNIT_OUTPUT: jest/test-report.xml
- run:
name: lint
command: npm run lint
- run:
name: codecov
command: bash <(curl -s https://codecov.io/bash)
- store_test_results:
path: jest
release:
docker:
- image: circleci/node:10
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run: npm install
- run: npm run build
- run: npm run semantic-release

workflows:
version: 2
test_and_release:
# Run the test jobs first, then the release only when all the test jobs are successful
jobs:
- test
- release:
filters:
branches:
only:
- master
requires:
- test
8 changes: 4 additions & 4 deletions example.js → example.ts
@@ -1,7 +1,7 @@
const redis = require('redis');
const Koa = require('koa');
import Koa from 'koa';
import redis from 'redis';

const ratelimit = require('./');
import ratelimit from './src';

const app = new Koa();

Expand All @@ -21,6 +21,6 @@ app.use((ctx, next) => {
});

app.listen(4000);
console.log('listening on port 4000');
console.log('listening on port http://localhost:4000');

module.exports = app;
121 changes: 0 additions & 121 deletions index.js

This file was deleted.

10 changes: 10 additions & 0 deletions jest.config.js
@@ -0,0 +1,10 @@
module.exports = {
roots: ['<rootDir>'],
reporters: ['default', 'jest-junit'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testEnvironment: 'node',
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.ts$',
moduleFileExtensions: ['ts', 'js'],
};

0 comments on commit ed1a4a4

Please sign in to comment.