Procházet zdrojové kódy

- Docs: Use syntax highlighting for JSON samples; use diacritics
- Refactoring: Add newline at end-of-file per convention (also makes diffs cleaner)
- Linting (ESLint): Add `eslint:recommended` with semi and indent rules
- Linting (npm): Add recommended `engines`, pointing to minimum Node LTS version (8+) and required by new nodemon
- Maintenance: Add `.editorconfig` to enforce consisting spacing in IDEs
- npm: Add `lint` script
- npm: Update deps (expres, fsevents) and devDep (nodemon)

Brett Zamir před 6 roky
rodič
revize
11c0fc84ba
9 změnil soubory, kde provedl 246 přidání a 660 odebrání
  1. 16 0
      .editorconfig
  2. 2 0
      .eslintignore
  3. 10 0
      .eslintrc.js
  4. 10 4
      README.md
  5. 1 1
      api/controllers/bDateController.js
  6. 1 1
      api/routes/bDateRoutes.js
  7. 196 650
      package-lock.json
  8. 9 3
      package.json
  9. 1 1
      server.js

+ 16 - 0
.editorconfig

@@ -0,0 +1,16 @@
+; EditorConfig file: https://EditorConfig.org
+; Install the "EditorConfig" plugin into your editor to use
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+
+; [app/public/css/**.styl]
+; indent_style = tab
+; indent_size = 2

+ 2 - 0
.eslintignore

@@ -0,0 +1,2 @@
+node_modules
+vendor

+ 10 - 0
.eslintrc.js

@@ -0,0 +1,10 @@
+module.exports = {
+  extends: ["eslint:recommended"],
+  env: {
+    node: true
+  },
+  rules: {
+    semi: ['error'],
+    indent: ['error', 2]
+  }
+};

+ 10 - 4
README.md

@@ -1,14 +1,14 @@
-# Baha'i Date RESTful API
+# Baháʼí Date RESTful API
 
 So far, there are two endpoints for this API:
 
 **GET /today**
 
-Returns today's date according to the Baha'i/Badi calendar.
+Returns today's date according to the Baháʼí/Badí' calendar.
 
 **POST /date**
 
-Given a date from the Gregorian calendar defined via POST data, returns the corresponding date in the Baha'i calendar.
+Given a date from the Gregorian calendar defined via POST data, returns the corresponding date in the Baháʼí calendar.
 
 ## Running
 
@@ -16,12 +16,13 @@ To launch the API server, simply navigate to the main folder and type 'npm run s
 
 ## Examples
 
-From either endpoint, the output is returned in a similar format: a JSON object containing a message, a Baha'i calendar date, and a Gregorian date/time.
+From either endpoint, the output is returned in a similar format: a JSON object containing a message, a Baháʼí calendar date, and a Gregorian date/time.
 
 ### Today
 
 URL: localhost:1844/today
 
+```json
 {
     "message": "Today is 13 Masá’il 174",
     "badi_date": {
@@ -39,6 +40,7 @@ URL: localhost:1844/today
         "second": 12
     }
 }
+```
 
 ### May 23, 1844
 
@@ -46,6 +48,7 @@ URL: localhost:1844/date?year=1844&month=5&day=23&hour=20&minute=45
 
 Output:
 
+```json
 {
     "message": "The date is: 9 ‘Aẓamat 1",
     "badi_date": {
@@ -63,6 +66,7 @@ Output:
         "second": 0
     }
 }
+```
 
 ### February 15, 2014
 
@@ -70,6 +74,7 @@ URL: localhost:1844/date?year=2014&month=2&day=15&hour=13&minute=45
 
 Output:
 
+```json
 {
     "message": "The date is: 10 Mulk 170",
     "badi_date": {
@@ -87,3 +92,4 @@ Output:
         "second": 0
     }
 }
+```

+ 1 - 1
api/controllers/bDateController.js

@@ -35,4 +35,4 @@ exports.date = function(req, res) {
   var now_badi = BadiCal.BadiDate.fromGregorianDate(now, here);
   res.json({ message: "The date is: " + now_badi.toString(),badi_date:{year:now_badi.getYear(),month:now_badi.getMonth(),day:now_badi.getDay(),month_name:now_badi.getMonthName()},greg_date:{year:year,month:month+1,day:day,hour:hour,minute:minute,second:second}});
   console.log("Date: " + now.toString() + " -> " + now_badi.toString());
-};
+};

+ 1 - 1
api/routes/bDateRoutes.js

@@ -11,4 +11,4 @@ module.exports = function(app) {
   // Arbitrary Badi date
   app.route('/date')
     .post(bDate.date);
-};
+};

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 196 - 650
package-lock.json


+ 9 - 3
package.json

@@ -4,9 +4,13 @@
   "description": "RESTful Baha'i date API",
   "main": "index.js",
   "scripts": {
+    "lint": "eslint .",
     "test": "echo \"Error: No test specified\" && exit 1",
     "start": "nodemon server.js"
   },
+  "engines": {
+    "node": ">=8.0.0"
+  },
   "repository": {
     "type": "git",
     "url": "git+https://github.com/dragfyre/bahai-date-api.git"
@@ -19,18 +23,20 @@
     "Baha'i"
   ],
   "author": "dragfyre",
+  "contributors": [],
   "license": "ISC",
   "bugs": {
     "url": "https://github.com/dragfyre/bahai-date-api/issues"
   },
   "homepage": "https://github.com/dragfyre/bahai-date-api#readme",
   "devDependencies": {
-    "nodemon": "^1.14.1"
+    "eslint": "^6.8.0",
+    "nodemon": "^2.0.2"
   },
   "dependencies": {
     "deep-extend": "^0.6.0",
-    "express": "^4.16.2",
-    "fsevents": "^2.0.1",
+    "express": "^4.17.1",
+    "fsevents": "^2.1.2",
     "randomatic": "^3.1.1",
     "rc": "^1.2.8"
   }

+ 1 - 1
server.js

@@ -11,4 +11,4 @@ routes(app); //register the route
 
 app.listen(port);
 
-console.log('Baha\'i Date RESTful API server started: Port ' + port);
+console.log('Baha\'i Date RESTful API server started: Port ' + port);

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů