Skip to content

Commit 8a3136c

Browse files
Merge branch 'master' into better-doc
2 parents ecdaee3 + d2ea86a commit 8a3136c

33 files changed

+878
-72
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@ jobs:
2626
2727
steps:
2828
- uses: actions/checkout@v3
29+
30+
- name: Shutdown Ubuntu MySQL
31+
run: sudo service mysql stop
32+
33+
- name: Setup MariaDB
34+
uses: getong/mariadb-action@v1.1
35+
with:
36+
mariadb version: '10.11.5'
37+
mysql user: 'directus'
38+
mysql password: 'password'
39+
mysql database: 'directus'
40+
41+
- name: Init MariaDB
42+
run: |
43+
sleep 5
44+
mysql -u directus -ppassword --database=directus --protocol=tcp < config/init.sql
45+
2946
- uses: actions/setup-node@v3
3047
with:
3148
node-version: 18.x

.mocharc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"exit": true,
3-
"timeout": 5000,
3+
"timeout": 10000,
44
"check-leaks": true,
55
"file": [
66
"test/setup.ts"

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ Hi! We're really excited that you're interested in contributing! Before submitti
1010

1111
## Project setup
1212

13-
In order to run the Globalping API locally you will need Node.js 18 and Redis with [RedisJSON](https://oss.redis.com/redisjson/) module (included in docker-compose.yml file). You will also need to run a development instance of the [Globalping Probe](https://github.com/jsdelivr/globalping-probe) at the same time when testing.
13+
In order to run the Globalping API locally you will need Node.js 18 and Redis with [RedisJSON](https://oss.redis.com/redisjson/) module and MariaDB. All of them are included in docker-compose.yml file. You will also need to run a development instance of the [Globalping Probe](https://github.com/jsdelivr/globalping-probe) at the same time when testing.
1414

1515
The API uses 3000 port by default. This can be overridden by `PORT` environment variable.
1616

1717
You can run the project by following these steps:
1818

1919
1. Clone this repository.
20-
2. `docker-compose up -d` - Run Redis
20+
2. `docker-compose up -d` - Run Redis and MariaDB
2121
3. `npm install`
22-
4. Run `npm run dev`
22+
4. Run `npm run start:dev`
2323

2424
Once the API is live, you can spin up a probe instance by running as described at https://github.com/jsdelivr/globalping-probe/blob/master/CONTRIBUTING.md.
2525

@@ -40,5 +40,7 @@ Most IDEs have plugins integrating the used linter (eslint), including support f
4040

4141
### Environment variables
4242

43-
- `NEW_RELIC_LICENSE_KEY={value}` environment variable should be used in production to send APM metrics to new relic
44-
- `NEW_RELIC_APP_NAME={value}` environment variable should be used in production to send APM mentrics to new relic
43+
- `NEW_RELIC_LICENSE_KEY={value}` used in production to send APM metrics to new relic
44+
- `NEW_RELIC_APP_NAME={value}` used in production to send APM mentrics to new relic
45+
- `NEW_RELIC_ENABLED=false` useid in development to disable newrelic monitoring
46+
- `FAKE_PROBE_IP={api|probe}` used in development to either use a random fake ip from the API or a fake ip from Probe

config/default.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ module.exports = {
1111
tls: false,
1212
},
1313
},
14+
db: {
15+
type: 'mysql',
16+
connection: 'mysql://directus:password@localhost:3306/directus',
17+
},
1418
admin: {
1519
key: '',
1620
},

config/init.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CREATE DATABASE IF NOT EXISTS directus;
2+
USE directus;
3+
4+
CREATE TABLE IF NOT EXISTS adopted_probes (
5+
id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
6+
user_created CHAR(36),
7+
date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
8+
user_updated CHAR(36),
9+
date_updated TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
10+
userId VARCHAR(255) NOT NULL,
11+
ip VARCHAR(255) NOT NULL,
12+
uuid VARCHAR(255),
13+
lastSyncDate DATE
14+
);
15+
INSERT IGNORE INTO adopted_probes (id, userId, ip) VALUES ('1', '6191378', '79.205.97.254');

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,14 @@ services:
88
volumes:
99
- ./config/redis.conf:/usr/local/etc/redis/redis.conf
1010
command: /usr/local/etc/redis/redis.conf
11+
12+
mariadb:
13+
image: mariadb:10.11.5
14+
environment:
15+
- MARIADB_RANDOM_ROOT_PASSWORD=1
16+
- MARIADB_USER=directus
17+
- MARIADB_PASSWORD=password
18+
ports:
19+
- "3306:3306"
20+
volumes:
21+
- ./config/init.sql:/docker-entrypoint-initdb.d/init.sql

knexfile.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import _ from 'lodash';
2+
import config from 'config';
3+
4+
const dbConfig = config.get('db');
5+
6+
/**
7+
* @typedef {import('knex').Knex.Config} KnexConfig
8+
* @type {{ [key: string]: KnexConfig }}
9+
*/
10+
export default _.merge({}, ...[ 'development', 'production', 'staging', 'test' ].map((environment) => {
11+
return {
12+
[environment]: {
13+
client: dbConfig.type,
14+
connection: dbConfig.connection,
15+
pool: {
16+
min: 0,
17+
max: 10,
18+
propagateCreateError: false,
19+
},
20+
acquireConnectionTimeout: 10000,
21+
},
22+
};
23+
}));

0 commit comments

Comments
 (0)