Skip to content

Commit

Permalink
Update setup (#3)
Browse files Browse the repository at this point in the history
* Configured prettier and a precommit hook

* Upgraded to typescript

* removed unused type definitions

* Generated file declarations

* added dockerfile

* Updated prettier and eslint configuration

* Updated tests and test running script

* Upgraded dependencies

* Updated type definitions on counties.ts

* Added travis CI

* Updated travis configuration

* Updated travis configuration

* Update nodjs version on travis
  • Loading branch information
kihuha authored Mar 16, 2021
1 parent 147494d commit b175397
Show file tree
Hide file tree
Showing 53 changed files with 9,366 additions and 1,434 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: {
es2021: true,
node: true,
},
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {},
ignorePatterns: ["dockerfile"],
}
23 changes: 0 additions & 23 deletions .eslintrc.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.lock
dockerfile
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"endOfLine": "lf",
"bracketSpacing": true,
"arrowParens": "always"
}
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
node_js:
- lts/*
install:
- npm install
script:
- npm run test -- --coverage
after_success:
- bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r ./coverage/lcov.info
14 changes: 0 additions & 14 deletions data/census-report-country.json

This file was deleted.

11 changes: 11 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:alpine

WORKDIR /usr/app

COPY ./package.json ./

RUN npm install

COPY ./ ./

CMD ["npm", "start"]
5 changes: 0 additions & 5 deletions index.js

This file was deleted.

53 changes: 46 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,57 @@
"main": "index.js",
"license": "MIT",
"scripts": {
"dev": "nodemon index.js",
"start": "node index.js",
"test": "jest --watchAll"
"build": "tsc",
"build:types": "tsc --declaration",
"dev": "nodemon public/index.js",
"start": "node public/index.js",
"test": "jest",
"format": "prettier --write src/**/*",
"lint": "eslint --fix-dry-run src/**/*"
},
"jest": {
"testEnvironment": "node"
"testEnvironment": "node",
"roots": [
"<rootDir>/src"
],
"testMatch": [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
}
},
"dependencies": {
"express": "^4.17.1"
"express": "^4.17.1",
"global": "^4.4.0",
"jest": "^26.6.3"
},
"devDependencies": {
"jest": "^25.3.0",
"supertest": "^4.0.2"
"@types/express": "^4.17.11",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.34",
"@types/supertest": "^2.0.10",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"eslint": "^7.22.0",
"husky": "=4",
"lint-staged": ">=10",
"nodemon": "^2.0.7",
"prettier": "^2.2.1",
"supertest": "^4.0.2",
"ts-jest": "^26.5.3",
"typescript": "^4.2.3"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*": [
"prettier --write src/**/*",
"eslint --fix"
]
}
}
2 changes: 2 additions & 0 deletions public/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const app: import("express-serve-static-core").Express
export default app
15 changes: 15 additions & 0 deletions public/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const country_1 = __importDefault(require("./routers/country"));
const counties_1 = __importDefault(require("./routers/counties"));
const app = express_1.default();
app.get("/", (req, res) => {
return res.json({ test: "Server is running" });
});
app.use("/api/v1/country", country_1.default);
app.use("/api/v1/counties", counties_1.default);
exports.default = app;
14 changes: 14 additions & 0 deletions public/data/country.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export declare const country: {
total: number
male: number
female: number
intersex: number
populationIn2009: number
popChange: number
households: number
averageHouseholds: number
popDensity: {
landArea: number
density: number
}
}
14 changes: 14 additions & 0 deletions public/data/country.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.country = void 0;
exports.country = {
total: 47564296,
male: 23548056,
female: 24014716,
intersex: 1524,
populationIn2009: 512690,
popChange: 108551,
households: 12143913,
averageHouseholds: 3.9,
popDensity: { landArea: 9123, density: 68 },
};
15 changes: 15 additions & 0 deletions public/data/countyData.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface Details {
male: number
female: number
intersex: number
households: number
averageHouseholds: number
popDensity: {
landArea: number
density: number
}
}
export interface County {
[key: string]: Details
}
export declare const counties: County
Loading

0 comments on commit b175397

Please sign in to comment.