Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cbdc63a

Browse files
config : add config for testing and development
1 parent f00e3e5 commit cbdc63a

File tree

6 files changed

+85
-39
lines changed

6 files changed

+85
-39
lines changed

‎config.js‎

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

‎config/config.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const developmentConfig = require('./development-config');
2+
const testConfig = require('./test-config');
3+
4+
if (process.env.NODE_PATH === 'test') {
5+
module.exports = testConfig;
6+
}
7+
else {
8+
module.exports = developmentConfig;
9+
}

‎config/development-config.js‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
exports = module.exports = {
2+
RUN: {
3+
TIMEOUT: process.env.RUN_TIMEOUT || 10000,
4+
},
5+
6+
// Domain/Host on which judge-api is hosted
7+
HOST: process.env.JUDGEAPI_HOST || 'localhost',
8+
// Port on which this app will run
9+
PORT: process.env.JUDGEAPI_PORT || 3737,
10+
11+
// Database config for a postgresql db (docker based or native)
12+
DB: {
13+
DATABASE: process.env.DB_NAME || 'judgeapi',
14+
USERNAME: process.env.DB_USER || 'judgeapi',
15+
PASSWORD: process.env.DB_PASS || 'judgeapi',
16+
HOST: process.env.DB_HOST || 'localhost'
17+
},
18+
19+
// Rabbit MQ queue - the other end of which is attached
20+
// to judge-taskmaster
21+
AMQP: {
22+
USER: process.env.AMQP_USER || 'codingblocks',
23+
PASS: process.env.AMQP_PASS || 'codingblocks',
24+
HOST: process.env.AMQP_HOST || 'localhost',
25+
PORT: process.env.AMQP_PORT || 5672
26+
},
27+
28+
S3: {
29+
endpoint: process.env.S3_ENDPOINT || 'localhost',
30+
port: process.env.S3_PORT || 9000,
31+
ssl: process.env.S3_SSL || false,
32+
accessKey: process.env.S3_ACCESS_KEY || '',
33+
secretKey: process.env.S3_SECRET_KEY || '',
34+
bucket: process.env.S3_BUCKET || 'judge-submissions',
35+
region: process.env.S3_REGION || 'us-east-1'
36+
}
37+
}

‎config/test-config.js‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
exports = module.exports = {
2+
RUN: {
3+
TIMEOUT: process.env.RUN_TIMEOUT || 10000,
4+
},
5+
6+
// Domain/Host on which judge-api is hosted
7+
HOST: process.env.JUDGEAPI_HOST || 'localhost',
8+
// Port on which this app will run
9+
PORT: process.env.JUDGEAPI_PORT || 3737,
10+
11+
// Database config for a postgresql db (docker based or native)
12+
DB: {
13+
DATABASE: process.env.DB_NAME || 'judgeapi-test',
14+
USERNAME: process.env.DB_USER || 'judgeapi',
15+
PASSWORD: process.env.DB_PASS || 'judgeapi',
16+
HOST: process.env.DB_HOST || 'localhost'
17+
},
18+
19+
// Rabbit MQ queue - the other end of which is attached
20+
// to judge-taskmaster
21+
AMQP: {
22+
USER: process.env.AMQP_USER || 'codingblocks',
23+
PASS: process.env.AMQP_PASS || 'codingblocks',
24+
HOST: process.env.AMQP_HOST || 'localhost',
25+
PORT: process.env.AMQP_PORT || 5672
26+
},
27+
28+
S3: {
29+
endpoint: process.env.S3_ENDPOINT || 'localhost',
30+
port: process.env.S3_PORT || 9000,
31+
ssl: process.env.S3_SSL || false,
32+
accessKey: process.env.S3_ACCESS_KEY || '',
33+
secretKey: process.env.S3_SECRET_KEY || '',
34+
bucket: process.env.S3_BUCKET || 'judge-submissions',
35+
region: process.env.S3_REGION || 'us-east-1'
36+
}
37+
}

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"apidoc": "apidoc -i src -o docs",
4949
"prestart": "npm run build && npm run apidoc",
5050
"start": "cross-env NODE_PATH=dist scripts/wait-for-it.sh localhost:5672 -- node dist/run.js",
51-
"test": "cross-env NODE_PATH=src node_modules/.bin/mocha --timeout 12000 --exit --require ts-node/register test/unit/validators/*.ts test/e2e/*.ts",
51+
"test": "cross-env NODE_PATH=src NODE_ENV=test mocha --timeout 12000 --exit --require ts-node/register test/unit/validators/*.ts test/e2e/*.ts",
5252
"cover": "nyc npm test",
5353
"seedlangs": "node dist/scripts/seed-defaultlangs.js",
5454
"precodecov": "npm run cover",

‎src/models/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as Sequelize from 'sequelize'
22
import * as path from 'path'
33
import * as fs from 'fs'
4-
import config = require('../../config')
54
import dbg = require('debug')
65

6+
const config = require('../../config/config');
77
const basename = path.basename(module.filename);
88
const db: any = {}
99
const dbModel = {}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /