Skip to content
This repository was archived by the owner on Sep 2, 2022. It is now read-only.

Commit 265eb31

Browse files
authored
Merge pull request #1 from apilytics/initial-version
Initial version
2 parents 53c598e + f7bb72b commit 265eb31

34 files changed

Lines changed: 6294 additions & 0 deletions

.eslintrc.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* eslint @typescript-eslint/no-var-requires: "off" */
2+
const builtins = require('module').builtinModules.join('|');
3+
4+
module.exports = {
5+
env: {
6+
node: true,
7+
},
8+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
9+
parser: '@typescript-eslint/parser',
10+
plugins: ['@typescript-eslint', 'simple-import-sort', 'import'],
11+
rules: {
12+
'@typescript-eslint/ban-ts-comment': 'off',
13+
'@typescript-eslint/no-empty-function': 'off',
14+
'@typescript-eslint/consistent-type-imports': 'error',
15+
'no-return-await': 'error',
16+
'import/no-duplicates': 'error',
17+
'simple-import-sort/imports': [
18+
'error',
19+
{
20+
groups: [
21+
['^\\u0000'],
22+
[`^(${builtins})(/.*)?(?<!\\u0000)$`, `^(${builtins})(/.*)?\\u0000$`],
23+
['(?<!\\u0000)$', '(?<=\\u0000)$'],
24+
['^\\.', '^\\..*\\u0000$'],
25+
],
26+
},
27+
],
28+
},
29+
overrides: [
30+
{
31+
files: ['*.ts'],
32+
rules: {
33+
'@typescript-eslint/explicit-function-return-type': ['error'],
34+
},
35+
},
36+
],
37+
ignorePatterns: ['dist/', 'coverage/'],
38+
};

.github/check_commits.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
head="$(git remote show origin | awk '/HEAD branch/ {print $NF}')"
4+
current="$(git rev-parse HEAD)"
5+
6+
if ! git merge-base --is-ancestor "origin/${head}" "$current"; then
7+
printf "Forgotten to rebase on top of %s.\nExiting with error!\n" "$head"
8+
exit 1
9+
fi
10+
11+
if [ "$(git rev-list --count --merges "origin/${head}..${current}")" -ne 0 ]; then
12+
printf "There are merge commits on the branch.\nExiting with error!\n"
13+
exit 1
14+
fi
15+
16+
echo Branch up-to-date and commits ok.

.github/workflows/ci.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: "CI"
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
concurrency:
9+
group: ci-${{ github.head_ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
commits:
14+
name: "Commits"
15+
if: ${{ github.event_name == 'pull_request' }}
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: "Checkout code"
19+
uses: actions/checkout@v2
20+
with:
21+
ref: ${{ github.event.pull_request.head.sha }}
22+
fetch-depth: 0
23+
24+
- name: "Check commits of the PR branch"
25+
run: ./.github/check_commits.sh
26+
27+
linters:
28+
name: "Linters"
29+
needs: commits
30+
if: ${{ !failure() }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: "Checkout code"
34+
uses: actions/checkout@v2
35+
36+
- name: "Set up Node"
37+
uses: actions/setup-node@v2
38+
with:
39+
node-version: '12'
40+
cache: 'yarn'
41+
42+
- name: "Install dependencies"
43+
run: yarn install --frozen-lockfile
44+
45+
- name: "Run linters"
46+
run: yarn lint
47+
48+
build:
49+
name: "Build"
50+
needs: commits
51+
if: ${{ !failure() }}
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: "Checkout code"
55+
uses: actions/checkout@v2
56+
57+
- name: "Set up Node"
58+
uses: actions/setup-node@v2
59+
with:
60+
node-version: '12'
61+
cache: 'yarn'
62+
63+
- name: "Install dependencies"
64+
run: yarn install --frozen-lockfile
65+
66+
- name: "Build the sources"
67+
run: yarn build
68+
69+
tests:
70+
name: "Tests"
71+
if: ${{ !failure() }}
72+
needs: [linters, build]
73+
strategy:
74+
fail-fast: true
75+
matrix:
76+
node-version: ['12', '14', '16', '17']
77+
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: "Checkout code"
81+
uses: actions/checkout@v2
82+
83+
- name: "Set up Node ${{ matrix.node-version }}"
84+
uses: actions/setup-node@v2
85+
with:
86+
node-version: ${{ matrix.node-version }}
87+
cache: 'yarn'
88+
89+
- name: "Install dependencies"
90+
run: yarn install --frozen-lockfile
91+
92+
- name: "Run type-checking"
93+
run: yarn type-check
94+
95+
- name: "Run tests"
96+
run: yarn test:cov
97+
98+
- name: "Upload coverage"
99+
if: matrix.node-version == '12'
100+
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.DS_Store
2+
3+
node_modules/
4+
5+
dist/
6+
*.tgz
7+
*.tsbuildinfo
8+
9+
coverage/
10+
*.log
11+
12+
.idea/
13+
.vscode/

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
coverage/

.prettierrc.json

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

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Initial version with Express and Next.js support.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Apilytics
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# apilytics-node
2+
3+
[![ci](https://github.com/apilytics/apilytics-node/actions/workflows/ci.yml/badge.svg)](https://github.com/apilytics/apilytics-node/actions/workflows/ci.yml)
4+
[![codecov](https://codecov.io/gh/apilytics/apilytics-node/branch/master/graph/badge.svg?token=K592YR52WQ)](https://codecov.io/gh/apilytics/apilytics-node)
5+
[![typescript](https://badgen.net/badge/icon/typescript?icon=typescript&label&color=007acc)](https://www.typescriptlang.org)
6+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
7+
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/apilytics/apilytics-node/blob/master/LICENSE)
8+
9+
## Installation
10+
11+
1. Sign up and get your API key from https://apilytics.io - we offer a completely free trial with no credit card required!
12+
13+
2. Check installation directions for your specific framework:
14+
15+
- [**Express**](./packages/express/README.md#installation)
16+
17+
- [**Next.js**](./packages/next/README.md#installation)
18+
19+
- [**Other Node.js Frameworks**](./packages/core/README.md#installation)

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2+
module.exports = {
3+
preset: 'ts-jest',
4+
testEnvironment: 'node',
5+
moduleDirectories: ['node_modules'],
6+
collectCoverageFrom: ['**/src/**/*.ts'],
7+
};

0 commit comments

Comments
 (0)