Skip to content

Commit 0c9637c

Browse files
committed
Port code to TypeScript
1 parent c293990 commit 0c9637c

34 files changed

+1450
-601
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
TestResults/
33
.vscode
4+
dist/

.eslintrc.json

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
{
22
"root": true,
3-
"env": {
4-
"node": true
5-
},
6-
"extends": "airbnb-base",
3+
"parser": "@typescript-eslint/parser",
74
"parserOptions": {
85
"ecmaVersion": 2018,
9-
"sourceType": "script"
6+
"sourceType": "module",
7+
"project": "./tsconfig.json"
108
},
9+
"plugins": ["@typescript-eslint", "import", "jest", "jsdoc"],
10+
"extends": [
11+
"eslint:recommended",
12+
"plugin:@typescript-eslint/recommended",
13+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
14+
"prettier/@typescript-eslint",
15+
"plugin:import/errors",
16+
"plugin:import/warnings",
17+
"plugin:import/typescript",
18+
"plugin:jsdoc/recommended",
19+
"plugin:jest/recommended",
20+
"plugin:prettier/recommended"
21+
],
1122
"rules": {
12-
"linebreak-style": "off",
13-
"no-use-before-define": [ "error", { "functions": false } ],
14-
"strict": [ "error", "global" ],
15-
"valid-jsdoc": "warn"
23+
"jsdoc/require-jsdoc": [
24+
"warn",
25+
{
26+
"publicOnly": true
27+
}
28+
]
1629
}
1730
}

.github/workflows/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,11 @@ jobs:
2222
- name: Yarn install
2323
run: yarn install
2424

25+
- name: Transpile
26+
run: yarn build
27+
2528
- name: Lint and run tests
2629
run: yarn test
30+
31+
- name: Pack
32+
run: npm pack

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
TestResults/
3-
.vscode
3+
.cache/
4+
dist/

.prettierrc.json

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

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"recommendations": [
33
"editorconfig.editorconfig",
44
"dbaeumer.vscode-eslint",
5+
"esbenp.prettier-vscode",
56
"firsttris.vscode-jest-runner",
67
"redhat.vscode-yaml",
78
]

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"editor.codeActionsOnSave": {
33
"source.fixAll": true
4-
}
4+
},
5+
"typescript.tsdk": "./node_modules/typescript/lib"
56
}

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
module.exports = {
4+
preset: 'ts-jest',
45
testEnvironment: 'node',
56
collectCoverage: true,
67
coverageDirectory: 'TestResults/coverage',

lib/jwk-store.js

Lines changed: 0 additions & 140 deletions
This file was deleted.

package.json

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,71 @@
1919
},
2020
"license": "MIT",
2121
"engines": {
22-
"node": ">=10.0.0",
22+
"node": "^10.13 || ^12.13",
2323
"yarn": "^1.15.2"
2424
},
2525
"repository": {
2626
"type": "git",
2727
"url": "https://github.com/axa-group/oauth2-mock-server.git"
2828
},
29-
"main": "index.js",
29+
"main": "./dist/index.js",
30+
"types": "./dist/index.d.ts",
3031
"bin": {
31-
"oauth2-mock-server": "./bin/oauth2-mock-server.js"
32+
"oauth2-mock-server": "./dist/oauth2-mock-server.js"
3233
},
3334
"files": [
3435
"CHANGELOG.md",
36+
"LICENSE.md",
3537
"README.md",
36-
"index.js",
37-
"bin/",
38-
"lib/"
38+
"dist/**/*.*"
3939
],
4040
"scripts": {
41+
"build:clean": "rimraf ./dist",
42+
"prebuild": "yarn build:clean",
43+
"build": "tsc -p ./tsconfig.build.json",
4144
"cleanup:testresults": "rimraf TestResults",
42-
"eslint": "eslint .",
43-
"pretest": "yarn cleanup:testresults && yarn eslint",
45+
"prelint": "tsc --noEmit",
46+
"lint": "eslint --cache --cache-location .cache/ --ext=.js,.ts src test --max-warnings 0",
47+
"pretest": "yarn cleanup:testresults && yarn lint",
4448
"test": "yarn jest"
4549
},
4650
"dependencies": {
51+
"@types/node-jose": "^1.1.5",
4752
"basic-auth": "^2.0.1",
4853
"body-parser": "^1.19.0",
4954
"cors": "^2.8.5",
5055
"express": "^4.17.1",
5156
"jsonwebtoken": "^8.5.1",
57+
"lodash.isplainobject": "^4.0.6",
5258
"node-jose": "^2.0.0",
5359
"uuid": "^8.3.0"
5460
},
5561
"devDependencies": {
62+
"@types/basic-auth": "^1.1.3",
63+
"@types/body-parser": "^1.19.0",
64+
"@types/cors": "^2.8.7",
65+
"@types/express": "^4.17.8",
66+
"@types/jest": "^26.0.14",
67+
"@types/jsonwebtoken": "^8.5.0",
68+
"@types/lodash.isplainobject": "^4.0.6",
69+
"@types/node": "^10.17.35",
70+
"@types/supertest": "^2.0.10",
71+
"@types/uuid": "^8.3.0",
72+
"@typescript-eslint/eslint-plugin": "^4.3.0",
73+
"@typescript-eslint/parser": "^4.3.0",
5674
"eslint": "^7.10.0",
57-
"eslint-config-airbnb-base": "^14.2.0",
75+
"eslint-config-prettier": "^6.12.0",
5876
"eslint-plugin-import": "^2.22.1",
5977
"eslint-plugin-jest": "^24.0.2",
78+
"eslint-plugin-jsdoc": "^30.6.3",
79+
"eslint-plugin-prettier": "^3.1.4",
6080
"jest": "^26.4.2",
6181
"jest-junit": "^11.1.0",
82+
"prettier": "^2.1.2",
6283
"rimraf": "^3.0.2",
63-
"supertest": "^5.0.0"
84+
"supertest": "^5.0.0",
85+
"ts-jest": "^26.4.1",
86+
"ts-node": "^9.0.0",
87+
"typescript": "^4.0.3"
6488
}
6589
}

index.js renamed to src/index.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
* limitations under the License.
1414
*/
1515

16-
'use strict';
17-
18-
const JWKStore = require('./lib/jwk-store');
19-
const OAuth2Issuer = require('./lib/oauth2-issuer');
20-
const OAuth2Server = require('./lib/oauth2-server');
21-
22-
module.exports = {
23-
JWKStore,
24-
OAuth2Issuer,
25-
OAuth2Server,
26-
};
16+
export { JWKStore } from './lib/jwk-store';
17+
export { OAuth2Issuer } from './lib/oauth2-issuer';
18+
export { OAuth2Server } from './lib/oauth2-server';

0 commit comments

Comments
 (0)