Skip to content

Commit 70a5e5b

Browse files
committed
first commit
0 parents  commit 70a5e5b

34 files changed

+13026
-0
lines changed

.eslintrc.cjs

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/* eslint-disable import/no-commonjs */
2+
module.exports = {
3+
extends: [
4+
'eslint:recommended',
5+
require.resolve('eslint-config-google'),
6+
],
7+
parserOptions: {
8+
sourceType: 'module',
9+
ecmaVersion: 2021,
10+
requireConfigFile: false,
11+
},
12+
env: {
13+
browser: false,
14+
mocha: true,
15+
node: true,
16+
es2021: true,
17+
},
18+
extends: [
19+
'eslint-config-prettier'
20+
],
21+
plugins: [
22+
'@babel',
23+
'no-only-tests',
24+
'import',
25+
],
26+
parser: '@babel/eslint-parser',
27+
rules: {
28+
'arrow-parens': [
29+
'error',
30+
'always',
31+
{
32+
'requireForBlockBody': true,
33+
},
34+
],
35+
'lines-between-class-members': 'error',
36+
'no-underscore-dangle': 'off',
37+
'import/no-namespace': 'off',
38+
'no-only-tests/no-only-tests': 'error',
39+
'import/extensions': [
40+
'error',
41+
'always',
42+
{
43+
ignorePackages: true,
44+
},
45+
],
46+
'import/prefer-default-export': 'off',
47+
'import/no-nodejs-modules': 'off',
48+
'import/no-extraneous-dependencies': [
49+
'error',
50+
{
51+
'devDependencies': [
52+
'**/test/**/*.js',
53+
'**/*.config.js',
54+
'**/*.conf.js',
55+
],
56+
},
57+
],
58+
'class-methods-use-this': [
59+
// this is unnecessary for node apps.
60+
'off',
61+
{
62+
'exceptMethods': [],
63+
},
64+
],
65+
'no-undef': 'error',
66+
'require-jsdoc': ['warn', {
67+
require: {
68+
FunctionDeclaration: true,
69+
MethodDefinition: true,
70+
ClassDeclaration: true,
71+
ArrowFunctionExpression: true,
72+
FunctionExpression: true,
73+
},
74+
}],
75+
'comma-dangle': 'off',
76+
'new-cap': [
77+
'error',
78+
{
79+
properties: false,
80+
capIsNew: false,
81+
},
82+
],
83+
'max-len': 'off',
84+
'object-curly-spacing': [
85+
'error',
86+
'always',
87+
],
88+
'no-console': [
89+
'error',
90+
],
91+
'no-unused-expressions': 'error',
92+
'prefer-template': 'error',
93+
'no-return-await': 'error',
94+
'no-template-curly-in-string': 'error',
95+
'indent': [
96+
'error',
97+
2,
98+
{
99+
SwitchCase: 1,
100+
VariableDeclarator: 1,
101+
outerIIFEBody: "off",
102+
MemberExpression: 0,
103+
ignoredNodes: ["CallExpression > FunctionExpression.callee > BlockStatement.body"],
104+
},
105+
],
106+
'no-shadow': [
107+
'error',
108+
{
109+
builtinGlobals: true,
110+
},
111+
],
112+
},
113+
114+
overrides: [
115+
{
116+
files: [
117+
'renderer/**/*.js',
118+
],
119+
env: {
120+
browser: true,
121+
},
122+
},
123+
{
124+
files: [
125+
'test/**/*.js',
126+
],
127+
rules: {
128+
'import/no-commonjs': 'off',
129+
'require-jsdoc': 'off',
130+
'import/no-extraneous-dependencies': 'off',
131+
},
132+
},
133+
],
134+
};

.github/workflows/codeql-analysis.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '21 7 * * 5'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
language: [ 'javascript' ]
32+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33+
# Learn more:
34+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v2
39+
40+
# Initializes the CodeQL tools for scanning.
41+
- name: Initialize CodeQL
42+
uses: github/codeql-action/init@v1
43+
with:
44+
languages: ${{ matrix.language }}
45+
# If you wish to specify custom queries, you can do so here or in a config file.
46+
# By default, queries listed here will override any specified in a config file.
47+
# Prefix the list here with "+" to use these queries and those in the config file.
48+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
49+
50+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51+
# If this step fails, then you should remove it and run the build manually (see below)
52+
- name: Autobuild
53+
uses: github/codeql-action/autobuild@v1
54+
55+
# ℹ️ Command-line programs to run using the OS shell.
56+
# 📚 https://git.io/JvXDl
57+
58+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59+
# and modify them (or add more) to build your code if your project
60+
# uses a compiled language
61+
62+
#- run: |
63+
# make bootstrap
64+
# make release
65+
66+
- name: Perform CodeQL Analysis
67+
uses: github/codeql-action/analyze@v1

.github/workflows/deployment.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Tests and publishing
2+
env:
3+
FORCE_COLOR: 1
4+
on:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
- develop
10+
pull_request:
11+
branches:
12+
- master
13+
- main
14+
jobs:
15+
test_linux:
16+
name: Ubuntu
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- uses: actions/setup-node@v1
21+
with:
22+
node-version: 14
23+
- uses: microsoft/playwright-github-action@v1
24+
- uses: actions/cache@v1
25+
with:
26+
path: ~/.npm
27+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
28+
restore-keys: |
29+
${{ runner.os }}-node-
30+
- name: Install dependencies
31+
run: npm ci
32+
- name: Run tests
33+
run: npm test
34+
tag:
35+
name: "Publishing release"
36+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
37+
needs:
38+
- test_linux
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v2
43+
with:
44+
fetch-depth: 0
45+
- uses: actions/setup-node@v2
46+
with:
47+
node-version: '14.x'
48+
registry-url: 'https://registry.npmjs.org'
49+
- uses: actions/cache@v1
50+
with:
51+
path: ~/.npm
52+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
53+
restore-keys: |
54+
${{ runner.os }}-node-
55+
- run: npm install
56+
- name: Read version from package.json
57+
uses: culshaw/read-package-node-version-actions@v1
58+
id: package-node-version
59+
- name: Changelog
60+
uses: scottbrenner/generate-changelog-action@master
61+
id: Changelog
62+
- name: Github Release
63+
id: create_release
64+
uses: actions/create-release@latest
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
with:
68+
tag_name: v${{ steps.package-node-version.outputs.version }}
69+
release_name: v${{ steps.package-node-version.outputs.version }}
70+
body: |
71+
${{ steps.Changelog.outputs.changelog }}
72+
draft: false
73+
prerelease: false
74+
- run: npm publish --access public
75+
env:
76+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# General
2+
.DS_Store
3+
.AppleDouble
4+
.LSOverride
5+
6+
# Icon must end with two \r
7+
Icon
8+
9+
10+
# Thumbnails
11+
._*
12+
13+
# Windows thumbnail cache files
14+
Thumbs.db
15+
ehthumbs.db
16+
ehthumbs_vista.db
17+
18+
# Dump file
19+
*.stackdump
20+
21+
# Folder config file
22+
[Dd]esktop.ini
23+
24+
# Recycle Bin used on file shares
25+
$RECYCLE.BIN/
26+
27+
# Windows Installer files
28+
*.cab
29+
*.msi
30+
*.msix
31+
*.msm
32+
*.msp
33+
34+
# Windows shortcuts
35+
*.lnk
36+
37+
.vscode/*
38+
!.vscode/settings.json
39+
!.vscode/tasks.json
40+
!.vscode/launch.json
41+
!.vscode/extensions.json
42+
43+
*~
44+
45+
# temporary files which can be created if a process still has a handle open of a deleted file
46+
.fuse_hidden*
47+
48+
# KDE directory preferences
49+
.directory
50+
51+
# Linux trash folder which might appear on any partition or disk
52+
.Trash-*
53+
54+
# .nfs files are created when an open file is removed but is still being accessed
55+
.nfs*
56+
57+
node_modules
58+
coverage

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
coverage/
2+
test/
3+
.*
4+
*.config.*

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cSpell.words": [
3+
"unzipper"
4+
]
5+
}

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {extends: ['@commitlint/config-conventional']}

dev/runner.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* eslint-disable no-console */
2+
/* eslint-disable import/no-extraneous-dependencies */
3+
import getPort from 'get-port';
4+
import chalk from 'chalk';
5+
import Server from '../index.js';
6+
7+
(async () => {
8+
// const port = await getPort();
9+
const port = 46739;
10+
const srv = new Server();
11+
srv.setupRoutes('/api/v1');
12+
await srv.startHttp(port);
13+
console.log(`The dev server started on port ${chalk.underline(port)}`);
14+
})();

index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export { Server as default } from './src/Server.js';
2+
export {
3+
ParserVendors,
4+
ParserMediaTypes,
5+
ServerConfiguration,
6+
ParserConfiguration,
7+
} from './types';

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Server as default } from './src/Server.js';

0 commit comments

Comments
 (0)