ソースを参照

add cities data

maguohua 8 年 前
コミット
52ad175d67
5 ファイル変更55 行追加24 行削除
  1. 22 22
      app.js
  2. 1 1
      config/default.js
  3. 1 1
      config/production.js
  4. 8 0
      controller/v1/cities.js
  5. 23 0
      models/v1/cities.js

+ 22 - 22
app.js

@@ -37,36 +37,36 @@ app.use(session({
 }))
 
 app.use((req, res, next) => {
-  res.locals.user = req.session.user;
-  res.locals.success = req.flash('success').toString();
-  res.locals.error = req.flash('error').toString();
-  next();
+    res.locals.user = req.session.user;
+    res.locals.success = req.flash('success').toString();
+    res.locals.error = req.flash('error').toString();
+    next();
 });
 
 app.use(expressWinston.logger({
-  transports: [
-    new (winston.transports.Console)({
-      json: true,
-      colorize: true
-    }),
-    new winston.transports.File({
-      filename: 'logs/success.log'
-    })
-  ]
+    transports: [
+        new (winston.transports.Console)({
+          json: true,
+          colorize: true
+        }),
+        new winston.transports.File({
+          filename: 'logs/success.log'
+        })
+    ]
 }));
 
 router(app);
 
 app.use(expressWinston.errorLogger({
-  transports: [
-    new winston.transports.Console({
-      json: true,
-      colorize: true
-    }),
-    new winston.transports.File({
-      filename: 'logs/error.log'
-    })
-  ]
+    transports: [
+        new winston.transports.Console({
+          json: true,
+          colorize: true
+        }),
+        new winston.transports.File({
+          filename: 'logs/error.log'
+        })
+    ]
 }));
 
 app.use((err, req, res, next) => {

+ 1 - 1
config/default.js

@@ -1,7 +1,7 @@
 'use strict';
 
 module.exports = {
-	port: 3000,
+	port: 8001,
 	url: 'mongodb://139.224.234.213:27017/elm',
 	session: {
 		name: 'elm',

+ 1 - 1
config/production.js

@@ -1,6 +1,6 @@
 'use strict';
 
 module.exports = {
-	port: 80,
+	port: 8001,
 	url: 'mongodb://localhost:27017/elm'
 }

+ 8 - 0
controller/v1/cities.js

@@ -0,0 +1,8 @@
+'use strict';
+
+class Cities {
+	constructor(){
+
+	}
+	
+}

+ 23 - 0
models/v1/cities.js

@@ -0,0 +1,23 @@
+'use strict';
+
+import mongoose from 'mongoose';
+
+const citySchema = new mongoose.Schema({
+	data: {
+		type: [{
+			id: Number,
+			name: String,
+			abbr: String,
+			area_code: String,
+			sort: Number,
+			latitude: Number,
+			longitude: Number,
+			is_map: Boolean,
+			pinyin: String,
+		}]
+	}
+});
+
+const Cities = mongoose.model('Cities', citySchema);
+
+export default Cities