Skip to content

Commit

Permalink
refactor: Linting the server side code (Third-Culture-Software#1612)
Browse files Browse the repository at this point in the history
* update .eslintrc.js and apply eslint in controllers/admin folder continues

* eslint controllers admin folder

* eslint controllers/dashboard folder

* eslint continues

* linting auth.js file

* eslint finance folder contnues

* eslint finance folder at server side continues

* eslint some report folder of the server

* eslint continues

* eslint some inventory and patient files

* editing rule for eol

* adding handlebars in the comfiguration
  • Loading branch information
DedrickEnc authored and jniles committed May 13, 2017
1 parent 212cdff commit cb96f6c
Show file tree
Hide file tree
Showing 84 changed files with 1,339 additions and 2,695 deletions.
12 changes: 9 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ module.exports = {
"comma-dangle" : ["error", "always-multiline"],
"key-spacing": ["warn", {
"singleLine": {
"beforeColon": false,
"beforeColon": true,
"afterColon": true
},
"multiLine": {
"beforeColon": true,
"afterColon": true,
"align" : "colon"
"mode" : "minimum"
}
}],
"no-use-before-define": ["error", {
Expand All @@ -35,7 +35,13 @@ module.exports = {
"func-names" : ["warn", "as-needed"],
"no-underscore-dangle": ["error", {
"allowAfterThis": true
}]
}],
"quotes" : ["error", "single", { "allowTemplateLiterals": true }],
"arrow-parens" : "off",
"arrow-body-style" : "off",
"prefer-arrow-callback" : "off",
"no-underscore-dangle" : "off",
"no-extra-boolean-cast" : "off",
},
"globals" : {
"Chart" : true,
Expand Down
14 changes: 12 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Declare files that will always have LF line endings on checkout.
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.js text eol=lf
*json text eol=lf
*.json text eol=lf
*.html text eol=lf
*.handlebars text eol=lf

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
3 changes: 2 additions & 1 deletion server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require('use-strict');
const http = require('http');
const express = require('express');
const winston = require('winston');
const dotEnv = require('dotenv');

const app = express();

Expand All @@ -50,7 +51,7 @@ function configureEnvironmentVariables() {

// load the environmental variables into process using the dotenv module
winston.info(`[app] Loading configuration from ${dotfile}.`);
require('dotenv').config({ path : dotfile });
dotEnv.config({ path: dotfile });
}

/**
Expand Down
26 changes: 12 additions & 14 deletions server/config/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
* @todo - this could probably be separated by functionality.
*/

const express = require('express');
const compress = require('compression');
const express = require('express');
const compress = require('compression');
const bodyParser = require('body-parser');
const session = require('express-session');
const session = require('express-session');
const RedisStore = require('connect-redis')(session);
const Redis = require('ioredis');
const morgan = require('morgan');
const fs = require('fs');
const winston = require('winston');
const _ = require('lodash');
const helmet = require('helmet');
const path = require('path');
const Redis = require('ioredis');
const morgan = require('morgan');
const winston = require('winston');
const _ = require('lodash');
const helmet = require('helmet');

const interceptors = require('./interceptors');
const Unauthorized = require('../lib/errors/Unauthorized');
Expand All @@ -34,8 +32,8 @@ exports.configure = function configure(app) {
app.use(helmet());
app.use(compress());

app.use(bodyParser.json({ limit: '8mb' }));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json({ limit : '8mb' }));
app.use(bodyParser.urlencoded({ extended : false }));

// this will disable the session from expiring on the server (redis-session)
// during development
Expand All @@ -52,7 +50,7 @@ exports.configure = function configure(app) {
resave : Boolean(process.env.SESS_RESAVE),
saveUninitialized : false,
unset : process.env.SESS_UNSET,
cookie : { httpOnly: true },
cookie : { httpOnly : true },
retries : 20,
};

Expand All @@ -72,7 +70,7 @@ exports.configure = function configure(app) {

// http logger setup
// options: combined | common | dev | short | tiny
app.use(morgan('combined', { stream: winston.stream }));
app.use(morgan('combined', { stream : winston.stream }));

// public static directories include the entire client and the uploads
// directory.
Expand Down
3 changes: 2 additions & 1 deletion server/config/interceptors.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ const SQL_STATES = {
*
* This error handler interprets all errors and sends them to the client.
*/
exports.handler = function handler(error, req, res, next) {
exports.handler = function handler(err, req, res, next) {
let error = err;
// log the error to the error log (NOTE: in production, this should be 'error')
winston.log('debug', error);

Expand Down
74 changes: 5 additions & 69 deletions server/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,33 @@ const medicalReports = require('../controllers/medical/reports');
const diagnoses = require('../controllers/medical/diagnoses');

// stock and inventory routes
const inventory = require('../controllers/inventory');
const depots = require('../controllers/inventory/depots');
const inventoryReports = require('../controllers/inventory/reports');
const stock = require('../controllers/stock');
const stockReports = require('../controllers/stock/reports');
const inventory = require('../controllers/inventory');
const depots = require('../controllers/inventory/depots');
const inventoryReports = require('../controllers/inventory/reports');
const stock = require('../controllers/stock');
const stockReports = require('../controllers/stock/reports');

// finance routes
const trialBalance = require('../controllers/finance/trialBalance');
const ledger = require('../controllers/finance/ledger');
const fiscal = require('../controllers/finance/fiscal');
const gl = require('../controllers/finance/ledgers/general');
const purchases = require('../controllers/finance/purchases');
const taxPayment = require('../controllers/finance/taxPayment');
const debtors = require('../controllers/finance/debtors');
const cashboxes = require('../controllers/finance/cashboxes');
const exchange = require('../controllers/finance/exchange');
const cash = require('../controllers/finance/cash');
const priceList = require('../controllers/finance/priceList');
const billingServices = require('../controllers/finance/billingServices');
const accounts = require('../controllers/finance/accounts');
const costCenter = require('../controllers/finance/costCenter');
const profitCenter = require('../controllers/finance/profitCenter');
const reference = require('../controllers/finance/reference');
const subsidies = require('../controllers/finance/subsidies');
const patientInvoice = require('../controllers/finance/patientInvoice');
const financeReports = require('../controllers/finance/reports');
const discounts = require('../controllers/finance/discounts');
const payroll = require('../controllers/finance/payroll');
const debtorGroups = require('../controllers/finance/debtors/groups');
const currencies = require('../controllers/finance/currencies');
const vouchers = require('../controllers/finance/vouchers');
const creditorGroups = require('../controllers/finance/creditorGroups');
const referenceGroup = require('../controllers/finance/referenceGroup');
const sectionResultats = require('../controllers/finance/sectionResultat');
const sectionBilans = require('../controllers/finance/sectionBilan');
const creditors = require('../controllers/finance/creditors.js');
const journal = require('../controllers/finance/journal');
const transactionType = require('../controllers/admin/transactionType');
Expand Down Expand Up @@ -152,57 +144,13 @@ exports.configure = function configure(app) {
app.post('/accounts', accounts.create);
app.put('/accounts/:id', accounts.update);

// API for cost_center routes CRUD
app.get('/cost_centers', costCenter.list);
app.get('/cost_centers/:id', costCenter.detail);
app.get('/cost_centers/:id/cost', costCenter.getCostValue);
app.post('/cost_centers', costCenter.create);
app.put('/cost_centers/:id', costCenter.update);
app.delete('/cost_centers/:id', costCenter.remove);

// API for service routes
app.post('/services', services.create);
app.get('/services', services.list);
app.get('/services/:id', services.detail);
app.put('/services/:id', services.update);
app.delete('/services/:id', services.remove);

// API for profit_center routes crud
app.get('/profit_centers', profitCenter.list);
app.get('/profit_centers/:id', profitCenter.detail);
app.get('/profit_centers/:id/profit', profitCenter.getProfitValue);
app.post('/profit_centers', profitCenter.create);
app.put('/profit_centers/:id', profitCenter.update);
app.delete('/profit_centers/:id', profitCenter.remove);

// API for reference routes crud
app.get('/references', reference.list);
app.get('/references/:id', reference.detail);
app.post('/references', reference.create);
app.put('/references/:id', reference.update);
app.delete('/references/:id', reference.remove);

// API for section resultats crud
app.get('/section_resultats', sectionResultats.list);
app.get('/section_resultats/:id', sectionResultats.detail);
app.post('/section_resultats', sectionResultats.create);
app.put('/section_resultats/:id', sectionResultats.update);
app.delete('/section_resultats/:id', sectionResultats.remove);

// API for section bilans crud
app.get('/section_bilans', sectionBilans.list);
app.get('/section_bilans/:id', sectionBilans.detail);
app.post('/section_bilans', sectionBilans.create);
app.put('/section_bilans/:id', sectionBilans.update);
app.delete('/section_bilans/:id', sectionBilans.remove);

// API for reference group crud
app.get('/reference_group', referenceGroup.list);
app.get('/reference_group/:id', referenceGroup.detail);
app.post('/reference_group', referenceGroup.create);
app.put('/reference_group/:id', referenceGroup.update);
app.delete('/reference_group/:id', referenceGroup.remove);

// API for subsidies routes crud
app.get('/subsidies', subsidies.list);
app.get('/subsidies/:id', subsidies.detail);
Expand Down Expand Up @@ -255,17 +203,6 @@ exports.configure = function configure(app) {
app.get('/getCheckHollyday/', employees.checkHoliday);
app.get('/getCheckOffday/', employees.checkOffday);

app.get('available_payment_period/', taxPayment.availablePaymentPeriod);
app.put('/setTaxPayment/', taxPayment.setTaxPayment);

// Payroll
app.get('/getDataPaiement/', payroll.listPaiementData);
app.get('/getEmployeePayment/:id', payroll.listPaymentByEmployee);
app.get('/getEnterprisePayment/:employee_id', payroll.listPaymentByEnterprise);
app.put('/setCotisationPayment/', payroll.setCotisationPayment);
app.get('/getEmployeeCotisationPayment/:id', payroll.listEmployeeCotisationPayments);
app.get('/taxe_ipr_currency/', payroll.listTaxCurrency);

/* Inventory and Stock Management */
app.post('/inventory/metadata', inventory.createInventoryItems);
app.get('/inventory/metadata', inventory.getInventoryItems);
Expand Down Expand Up @@ -613,7 +550,6 @@ exports.configure = function configure(app) {
// stock management API
app.post('/stock/lots/movements', stock.createMovement);
app.get('/stock/lots/movements', stock.listLotsMovements);

app.post('/stock/lots', stock.createStock);
app.get('/stock/lots', stock.listLots);
app.get('/stock/lots/origins', stock.listLotsOrigins);
Expand Down
Loading

0 comments on commit cb96f6c

Please sign in to comment.