Skip to content

Commit 67301be

Browse files
UI-1 (#9)
* added eslint * UI-1: Added config, logger, routes, util and pug * UI-1: Added views and index view, styles header fonts * a lot of style * UI-1: Added grunt copy and replace
1 parent 81ca9ce commit 67301be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2660
-206
lines changed

.eslintrc.js

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
module.exports = {
2+
"env": {
3+
"es6": true,
4+
"node": true,
5+
"browser": true
6+
},
7+
"extends": "eslint:recommended",
8+
"parserOptions": {
9+
"ecmaVersion": 2018
10+
},
11+
"rules": {
12+
"no-console": ["error", { allow: ["warn", "error"] }],
13+
"accessor-pairs": "error",
14+
"array-bracket-newline": "error",
15+
"array-bracket-spacing": [
16+
"error",
17+
"never"
18+
],
19+
"array-callback-return": "error",
20+
"array-element-newline": "off",
21+
"arrow-body-style": "error",
22+
"arrow-parens": "error",
23+
"arrow-spacing": "error",
24+
"block-scoped-var": "error",
25+
"block-spacing": "error",
26+
"brace-style": [
27+
"error",
28+
"1tbs"
29+
],
30+
"callback-return": "error",
31+
"camelcase": "off",
32+
"capitalized-comments": "off",
33+
"class-methods-use-this": "error",
34+
"comma-dangle": "error",
35+
"comma-spacing": "off",
36+
"comma-style": [
37+
"error",
38+
"last"
39+
],
40+
"complexity": "error",
41+
"computed-property-spacing": [
42+
"error",
43+
"never"
44+
],
45+
"consistent-return": "off",
46+
"consistent-this": "error",
47+
"curly": "error",
48+
"default-case": "error",
49+
"dot-location": [
50+
"error",
51+
"property"
52+
],
53+
"dot-notation": "error",
54+
"eol-last": "error",
55+
"eqeqeq": "off",
56+
"func-call-spacing": "error",
57+
"func-name-matching": "error",
58+
"func-names": "off",
59+
"func-style": [
60+
"error",
61+
"declaration"
62+
],
63+
"function-paren-newline": "off",
64+
"generator-star-spacing": "error",
65+
"global-require": "error",
66+
"guard-for-in": "off",
67+
"handle-callback-err": "error",
68+
"id-blacklist": "error",
69+
"id-length": "off",
70+
"id-match": "error",
71+
"implicit-arrow-linebreak": "error",
72+
"indent": "off",
73+
"indent-legacy": "off",
74+
"init-declarations": "error",
75+
"jsx-quotes": "error",
76+
"key-spacing": "error",
77+
"keyword-spacing": [
78+
"error",
79+
{
80+
"after": true,
81+
"before": true
82+
}
83+
],
84+
"line-comment-position": "error",
85+
"linebreak-style": [
86+
"error",
87+
"unix"
88+
],
89+
"lines-around-comment": "off",
90+
"lines-around-directive": "error",
91+
"lines-between-class-members": "error",
92+
"max-classes-per-file": "off",
93+
"max-depth": "error",
94+
"max-len": "off",
95+
"max-lines": "error",
96+
"max-lines-per-function": "off",
97+
"max-nested-callbacks": "error",
98+
"max-params": "error",
99+
"max-statements": "off",
100+
"max-statements-per-line": "error",
101+
"multiline-comment-style": "off",
102+
"new-cap": "error",
103+
"new-parens": "error",
104+
"newline-after-var": "off",
105+
"newline-before-return": "off",
106+
"newline-per-chained-call": "off",
107+
"no-alert": "error",
108+
"no-array-constructor": "error",
109+
"no-async-promise-executor": "off",
110+
"no-await-in-loop": "error",
111+
"no-bitwise": "error",
112+
"no-buffer-constructor": "error",
113+
"no-caller": "error",
114+
"no-catch-shadow": "error",
115+
"no-confusing-arrow": "error",
116+
"no-continue": "error",
117+
"no-div-regex": "error",
118+
"no-duplicate-imports": "error",
119+
"no-else-return": "error",
120+
"no-empty-function": "error",
121+
"no-eq-null": "error",
122+
"no-eval": "error",
123+
"no-extend-native": "error",
124+
"no-extra-bind": "error",
125+
"no-extra-label": "error",
126+
"no-extra-parens": "off",
127+
"no-floating-decimal": "error",
128+
"no-implicit-coercion": "error",
129+
"no-implicit-globals": "off",
130+
"no-implied-eval": "error",
131+
"no-inline-comments": "error",
132+
"no-inner-declarations": [
133+
"error",
134+
"functions"
135+
],
136+
"no-invalid-this": "error",
137+
"no-iterator": "error",
138+
"no-label-var": "error",
139+
"no-labels": "error",
140+
"no-lone-blocks": "error",
141+
"no-lonely-if": "error",
142+
"no-loop-func": "error",
143+
"no-magic-numbers": "off",
144+
"no-misleading-character-class": "off",
145+
"no-mixed-operators": "error",
146+
"no-mixed-requires": "off",
147+
"no-multi-assign": "error",
148+
"no-multi-spaces": "off",
149+
"no-multi-str": "error",
150+
"no-multiple-empty-lines": "error",
151+
"no-native-reassign": "error",
152+
"no-negated-condition": "off",
153+
"no-negated-in-lhs": "error",
154+
"no-nested-ternary": "off",
155+
"no-new": "error",
156+
"no-new-func": "error",
157+
"no-new-object": "error",
158+
"no-new-require": "error",
159+
"no-new-wrappers": "error",
160+
"no-octal-escape": "error",
161+
"no-param-reassign": "error",
162+
"no-path-concat": "error",
163+
"no-plusplus": [
164+
"error",
165+
{
166+
"allowForLoopAfterthoughts": true
167+
}
168+
],
169+
"no-process-env": "off",
170+
"no-process-exit": "error",
171+
"no-proto": "error",
172+
"no-prototype-builtins": "error",
173+
"no-restricted-globals": "error",
174+
"no-restricted-imports": "error",
175+
"no-restricted-modules": "error",
176+
"no-restricted-properties": "error",
177+
"no-restricted-syntax": "error",
178+
"no-return-assign": "error",
179+
"no-return-await": "error",
180+
"no-script-url": "error",
181+
"no-self-compare": "error",
182+
"no-sequences": "error",
183+
"no-shadow": "off",
184+
"no-shadow-restricted-names": "error",
185+
"no-spaced-func": "error",
186+
"no-sync": "error",
187+
"no-tabs": "off",
188+
"no-template-curly-in-string": "error",
189+
"no-ternary": "off",
190+
"no-throw-literal": "error",
191+
"no-trailing-spaces": "error",
192+
"no-undef-init": "error",
193+
"no-undefined": "error",
194+
"no-underscore-dangle": "error",
195+
"no-unmodified-loop-condition": "error",
196+
"no-unneeded-ternary": "error",
197+
"no-unused-expressions": "error",
198+
"no-use-before-define": "error",
199+
"no-useless-call": "error",
200+
"no-useless-computed-key": "error",
201+
"no-useless-concat": "off",
202+
"no-useless-constructor": "error",
203+
"no-useless-rename": "error",
204+
"no-useless-return": "error",
205+
"no-var": "off",
206+
"no-void": "error",
207+
"no-warning-comments": "error",
208+
"no-whitespace-before-property": "error",
209+
"no-with": "error",
210+
"nonblock-statement-body-position": "error",
211+
"object-curly-newline": "off",
212+
"object-curly-spacing": "off",
213+
"object-property-newline": "error",
214+
"object-shorthand": "error",
215+
"one-var": "off",
216+
"one-var-declaration-per-line": "off",
217+
"operator-assignment": "error",
218+
"operator-linebreak": "error",
219+
"padded-blocks": "off",
220+
"padding-line-between-statements": "error",
221+
"prefer-arrow-callback": "off",
222+
"prefer-const": "error",
223+
"prefer-destructuring": "error",
224+
"prefer-numeric-literals": "error",
225+
"prefer-object-spread": "off",
226+
"prefer-promise-reject-errors": "error",
227+
"prefer-reflect": "error",
228+
"prefer-rest-params": "error",
229+
"prefer-spread": "error",
230+
"prefer-template": "off",
231+
"quote-props": "off",
232+
"quotes": "off",
233+
"radix": "error",
234+
"require-atomic-updates": "off",
235+
"require-await": "error",
236+
"require-jsdoc": "off",
237+
"require-unicode-regexp": "off",
238+
"rest-spread-spacing": "error",
239+
"semi": "error",
240+
"semi-spacing": [
241+
"error",
242+
{
243+
"after": true,
244+
"before": false
245+
}
246+
],
247+
"semi-style": [
248+
"error",
249+
"last"
250+
],
251+
"sort-imports": "error",
252+
"sort-keys": "error",
253+
"sort-vars": "off",
254+
"space-before-blocks": "off",
255+
"space-before-function-paren": "off",
256+
"space-in-parens": [
257+
"error",
258+
"never"
259+
],
260+
"space-infix-ops": "off",
261+
"space-unary-ops": "error",
262+
"spaced-comment": "off",
263+
"strict": [
264+
"error",
265+
"never"
266+
],
267+
"switch-colon-spacing": "error",
268+
"symbol-description": "error",
269+
"template-curly-spacing": "error",
270+
"template-tag-spacing": "error",
271+
"unicode-bom": [
272+
"error",
273+
"never"
274+
],
275+
"valid-jsdoc": "error",
276+
"vars-on-top": "off",
277+
"wrap-iife": "error",
278+
"wrap-regex": "error",
279+
"yield-star-spacing": "error",
280+
"yoda": [
281+
"error",
282+
"never"
283+
]
284+
}
285+
};

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules/
22
package-lock.json
33
config.json
4+
.DS_Store
5+
.sass-cache/

config.js

Lines changed: 0 additions & 12 deletions
This file was deleted.
File renamed without changes.

config/index.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*eslint no-sync: "off"*/
2+
3+
const fs = require('fs'),
4+
firebase = require('firebase'),
5+
logger = require('./../logger')(__dirname),
6+
configFilePath = './config/config.json';
7+
8+
var config = {},
9+
configLoaded = false;
10+
11+
function initConfig() {
12+
if (configLoaded) {
13+
return;
14+
}
15+
if (fs.existsSync(configFilePath)) {
16+
logger.info(`configuration loaded from ${configFilePath} file`);
17+
config = JSON.parse(fs.readFileSync(configFilePath));
18+
configLoaded = true;
19+
} else if (typeof process.env.REWARDS_CONFIG !== 'undefined') {
20+
config = JSON.parse(process.env.REWARDS_CONFIG);
21+
logger.info('config loaded from ENV');
22+
} else {
23+
logger.error(`there is no ${configFilePath} file or REWARDS_CONFIG env var.`);
24+
}
25+
// logger.info(JSON.stringify(config.firebase));
26+
// firebase.initializeApp(config.firebase);
27+
}
28+
29+
initConfig();
30+
31+
module.exports = {
32+
get: (name, defaultValue) => {
33+
if (typeof process.env[name] !== 'undefined') {
34+
logger.info(`process.env.${name} found`);
35+
return process.env[name];
36+
}
37+
if (typeof config[name] !== 'undefined') {
38+
return config[name];
39+
}
40+
if (typeof defaultValue !== 'undefined') {
41+
return defaultValue;
42+
}
43+
logger.error(`[${name}] does not exists`);
44+
return null;
45+
},
46+
getAll: () => config,
47+
getApp: async () => {
48+
const configApp = await firebase.database().ref('config').once('value');
49+
return configApp;
50+
},
51+
getRewards: () => {
52+
const configRewards = firebase.database().ref('rewards').once('value');
53+
logger.info(JSON.stringify(configRewards));
54+
return configRewards;
55+
},
56+
set: (name, value) => firebase.database().ref('config/' + name).set(value)
57+
};

firebase_db.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
var firebase = require('firebase'),
2-
fs = require('fs'),
3-
config = require('./config.js');
2+
config = require('./config');
43

54
const default_user = {
65
coins: 5,
76
total_coins: 0
87
};
98

10-
firebase.initializeApp(config.firebase);
9+
firebase.initializeApp(config.get('firebase'));
1110

1211
function sendTokens(giverId, receiversIds, tokenQuantity, eachTransaction) {
1312
var i = 0;

0 commit comments

Comments
 (0)