-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
846bd0b
commit 2c4e0f3
Showing
53 changed files
with
10,656 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = tab | ||
|
||
[*.md] | ||
indent_style = space | ||
|
||
[*.{yaml,yml}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"extends": "@martin-kolarik/eslint-config/typescript", | ||
"ignorePatterns": [ | ||
"coverage/**", | ||
"data/**", | ||
"dist/**" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"src/**/*.ts" | ||
], | ||
"extends": "@martin-kolarik/eslint-config/typescript-type-checking", | ||
"parserOptions": { | ||
"project": true | ||
} | ||
}, | ||
{ | ||
"files": [ | ||
"**" | ||
], | ||
"rules": { | ||
"no-duplicate-imports": "off", | ||
"no-extra-parens": "off" | ||
} | ||
}, | ||
{ | ||
"files": [ | ||
"public/**" | ||
], | ||
"parserOptions": { | ||
"sourceType": "script" | ||
}, | ||
"rules": { | ||
"no-undef": "off", | ||
"no-unused-vars": "off" | ||
} | ||
}, | ||
{ | ||
"files": [ | ||
"test/**" | ||
], | ||
"rules": { | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"no-restricted-properties": [ | ||
"error", | ||
{ | ||
"object": "sinon", | ||
"property": "spy" | ||
}, | ||
{ | ||
"object": "sinon", | ||
"property": "stub" | ||
}, | ||
{ | ||
"object": "sinon", | ||
"property": "mock" | ||
}, | ||
{ | ||
"object": "sinon", | ||
"property": "fake" | ||
}, | ||
{ | ||
"object": "sinon", | ||
"property": "restore" | ||
}, | ||
{ | ||
"object": "sinon", | ||
"property": "reset" | ||
}, | ||
{ | ||
"object": "sinon", | ||
"property": "resetHistory" | ||
}, | ||
{ | ||
"object": "sinon", | ||
"property": "resetBehavior" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# These are supported funding model platforms | ||
github: jsdelivr | ||
open_collective: jsdelivr | ||
custom: ['https://www.jsdelivr.com/sponsors'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ "*" ] | ||
pull_request: | ||
branches: [ "*" ] | ||
|
||
jobs: | ||
build: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
NODE_ENV: test | ||
|
||
services: | ||
redis: | ||
image: redis/redis-stack-server:latest | ||
ports: | ||
- 16379:6379 | ||
options: >- | ||
--health-cmd "redis-cli ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
mariadb: | ||
image: mariadb:10.11.5 | ||
ports: | ||
- 13306:3306 | ||
env: | ||
MARIADB_DATABASE: dashboard-globalping-test | ||
MARIADB_USER: directus | ||
MARIADB_PASSWORD: password | ||
MARIADB_RANDOM_ROOT_PASSWORD: 1 | ||
options: >- | ||
--health-cmd "mysqladmin ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.x | ||
- name: Build | ||
run: | | ||
npm ci | ||
npm run build | ||
- name: Test Unit, Integration | ||
run: | | ||
npm run lint | ||
npm run coverage | ||
- name: Test Dist | ||
run: | | ||
rm -rf node_modules | ||
npm ci --omit=dev | ||
npm run test:dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.idea/ | ||
.vscode/ | ||
.nyc_output/ | ||
node_modules/ | ||
coverage/ | ||
dist/ | ||
tmp/ | ||
config/local* | ||
.eslintcache | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module.exports = { | ||
'exit': true, | ||
'timeout': 10000, | ||
'check-leaks': true, | ||
'file': [ | ||
'test/setup.ts', | ||
], | ||
'spec': [ | ||
// 'test/tests/unit/**/*.test.ts', | ||
'test/tests/integration/**/*.test.ts', | ||
], | ||
'node-option': [ | ||
'enable-source-maps', | ||
'experimental-specifier-resolution=node', | ||
'loader=ts-node/esm', | ||
], | ||
'globals': [ | ||
'__extends', | ||
'__assign', | ||
'__rest', | ||
'__decorate', | ||
'__param', | ||
'__metadata', | ||
'__awaiter', | ||
'__generator', | ||
'__exportStar', | ||
'__createBinding', | ||
'__values', | ||
'__read', | ||
'__spread', | ||
'__spreadArrays', | ||
'__spreadArray', | ||
'__await', | ||
'__asyncGenerator', | ||
'__asyncDelegator', | ||
'__asyncValues', | ||
'__makeTemplateObject', | ||
'__importStar', | ||
'__importDefault', | ||
'__classPrivateFieldGet', | ||
'__classPrivateFieldSet', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE DATABASE IF NOT EXISTS `dashboard-globalping`; | ||
GRANT ALL PRIVILEGES ON `dashboard-globalping`.* to 'directus'@'%'; | ||
|
||
CREATE DATABASE IF NOT EXISTS `dashboard-globalping-test`; | ||
GRANT ALL PRIVILEGES ON `dashboard-globalping-test`.* to 'directus'@'%'; | ||
|
||
-- Directus issue https://github.com/directus/directus/discussions/11786 | ||
ALTER DATABASE `dashboard-globalping` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
ALTER DATABASE `dashboard-globalping-test` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const _ = require('lodash'); | ||
const df = require('./default.cjs'); | ||
|
||
function mapEnvConfig (object, prefix = '') { | ||
return _.mapValues(object, (value, key) => { | ||
if (_.isObject(value)) { | ||
return mapEnvConfig(value, (prefix ? `${prefix}_` : '') + _.snakeCase(key).toUpperCase()); | ||
} | ||
|
||
return (prefix ? `${prefix}_` : '') + _.snakeCase(key).toUpperCase(); | ||
}); | ||
} | ||
|
||
const mapped = mapEnvConfig(df); | ||
|
||
module.exports = mapped; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = { | ||
server: { | ||
host: 'https://auth.globalping.io', | ||
docsHost: 'https://www.jsdelivr.com', | ||
dashHost: 'https://dash.globalping.io', | ||
directusHost: 'https://dash-directus.globalping.io', | ||
port: 13110, | ||
processes: 1, | ||
session: { | ||
cookieName: 'dash_session_token', | ||
cookieSecret: '', | ||
}, | ||
}, | ||
redis: { | ||
url: 'redis://localhost:6379', | ||
socket: { | ||
tls: false, | ||
}, | ||
}, | ||
db: { | ||
type: 'mysql', | ||
connection: { | ||
host: 'localhost', | ||
user: 'directus', | ||
password: 'password', | ||
database: 'dashboard-globalping', | ||
port: 3306, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
server: { | ||
host: 'http://localhost:13110', | ||
dashHost: 'http://localhost:13010', | ||
directusHost: 'http://localhost:18055', | ||
session: { | ||
cookieSecret: 'xxx', | ||
}, | ||
}, | ||
redis: { | ||
url: 'redis://localhost:16379', | ||
socket: { | ||
tls: false, | ||
}, | ||
}, | ||
db: { | ||
connection: { | ||
port: 13306, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
server: { | ||
session: { | ||
cookieSecret: 'xxx', | ||
}, | ||
}, | ||
redis: { | ||
url: 'redis://localhost:16379', | ||
socket: { | ||
tls: false, | ||
}, | ||
}, | ||
db: { | ||
connection: { | ||
port: 13306, | ||
database: 'dashboard-globalping-test', | ||
multipleStatements: true, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import _ from 'lodash'; | ||
import config from 'config'; | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
const dbConfig = config.get('db'); | ||
|
||
/** | ||
* @typedef {import('knex').Knex.Config} KnexConfig | ||
* @type {{ [key: string]: KnexConfig }} | ||
*/ | ||
export default _.merge({}, ...[ 'development', 'production', 'staging', 'test' ].map((environment) => { | ||
return { | ||
[environment]: { | ||
client: dbConfig.type, | ||
connection: dbConfig.connection, | ||
pool: { | ||
min: 0, | ||
max: 10, | ||
propagateCreateError: false, | ||
}, | ||
acquireConnectionTimeout: 5000, | ||
seeds: { | ||
directory: path.join(__dirname, `./seeds/${environment}`), | ||
}, | ||
migrations: { | ||
directory: path.join(__dirname, `./migrations`), | ||
}, | ||
}, | ||
}; | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import fs from 'node:fs'; | ||
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
export const up = async (db) => { | ||
const __filename = fileURLToPath(import.meta.url); | ||
const query = fs.readFileSync(path.join(__filename + '.sql'), 'utf8'); | ||
await db.schema.raw(query); | ||
}; | ||
|
||
export const down = () => {}; |
Oops, something went wrong.