Skip to content

Commit

Permalink
[deni]: Fix writing script with eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmatin99 committed Jan 23, 2018
1 parent 1baa954 commit 294ca43
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 39 deletions.
18 changes: 9 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import express from "express";
import bodyParser from "body-parser";
import accessLog from "morgan";
import path from "path";
import fs from "fs";
import config from "./common/config.json";
import dateFormat from "dateformat";
import routes from "./routes";
import express from 'express';
import bodyParser from 'body-parser';
import accessLog from 'morgan';
import path from 'path';
import fs from 'fs';
import config from './common/config.json';
import dateFormat from 'dateformat';
import routes from './routes';

const app = express();
const accessLogStream = fs.createWriteStream(
path.join(__dirname, `${config.development.accessLog}/access-${dateFormat(new Date(), "yyyymmdd")}.log`),
path.join(__dirname, `${config.development.accessLog}/access-${dateFormat(new Date(), 'yyyymmdd')}.log`),
{flags: 'a'}
);

Expand Down
14 changes: 7 additions & 7 deletions controllers/listing.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import listingService from "../services/ListingService";
import listingService from '../services/ListingService';

export const getAllListings = async (req, res, next) => {
export const getAllListings = async (req, res) => {
const data = await listingService.getAllListings();
res
.status(200)
.json({code: 200, data:data, message: "SUCCESS"})
.json({code: 200, data:data, message: 'SUCCESS'})
.end();
}
};

export const getListingById = async (req, res, next) => {
export const getListingById = async (req, res) => {
const data = await listingService.getListingById(req.params.id);
res
.status(200)
.json({code: 200, data: data, message: "SUCCESS"})
.json({code: 200, data: data, message: 'SUCCESS'})
.end();
}
};
6 changes: 3 additions & 3 deletions dao/Solr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import solr from "solr-client";
import config from "./SolrConfig.json";
import bluebird from "bluebird";
import solr from 'solr-client';
import config from './SolrConfig.json';
import bluebird from 'bluebird';

export default class SolrClient {

Expand Down
4 changes: 2 additions & 2 deletions dao/solr/listing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Solr from "../Solr";
import Solr from '../Solr';

const CORE_LISTING = "listing";
const CORE_LISTING = 'listing';

export class Listing extends Solr {

Expand Down
162 changes: 162 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"start": "nodemon --exec NODE_ENV=development PORT=3001 babel-node ./bin/server",
"test:unit": "cross-env NODE_ENV=test nyc mocha tests/unit",
"test:integration": "cross-env NODE_ENV=test nyc mocha tests/integration"
"test:integration": "cross-env NODE_ENV=test nyc mocha tests/integration",
"fixLint": "eslint app.js --fix"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -34,6 +35,7 @@
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.1",
"babel-plugin-istanbul": "^4.1.5",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
Expand Down
10 changes: 5 additions & 5 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import listingRouter from "./routers/listing";
import express from "express";
import listingRouter from './routers/listing';
import express from 'express';

export default (app) => {
const router = express.Router();
router.use("/listing", listingRouter);
app.use("/v1", router);
}
router.use('/listing', listingRouter);
app.use('/v1', router);
};
8 changes: 4 additions & 4 deletions routes/routers/listing.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import express from "express";
import { getAllListings, getListingById } from "../../controllers/listing";
import express from 'express';
import { getAllListings, getListingById } from '../../controllers/listing';

const router = express.Router();

router.get("/", getAllListings);
router.get("/:id", getListingById);
router.get('/', getAllListings);
router.get('/:id', getListingById);

export default router;
2 changes: 1 addition & 1 deletion services/BaseService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import config from "../common/config.json";
import config from '../common/config.json';

export default class BaseService {

Expand Down
13 changes: 6 additions & 7 deletions services/ListingService.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import BaseService from "./BaseService";
import ListingModel from "../dao/solr/listing";
// import BaseService from "./BaseService";
import ListingModel from '../dao/solr/listing';

export class ListingService extends BaseService {
export class ListingService {

constructor(listingModel) {
super();
// super();
this.listingModel = listingModel;
}
async getAllListings() {
const listingCollection = await this.listingModel.search();
const slorStatus = listingCollection.responseHeader.status;

if (slorStatus !== 0) {
if (slorStatus !== 0)
throw new Error('Solr search error!');
}

return {
number: listingCollection.response.numFound,
Expand All @@ -31,7 +30,7 @@ export class ListingService extends BaseService {
return {
number: 1,
listing: listingCollection.response.docs[0]
}
};
}
}

Expand Down

0 comments on commit 294ca43

Please sign in to comment.